Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | 524b588 | 1995-01-04 19:10:35 +0000 | [diff] [blame] | 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 | The Netherlands. |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 4 | |
| 5 | All Rights Reserved |
| 6 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame^] | 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 9 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame^] | 10 | both that copyright notice and this permission notice appear in |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 11 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame^] | 12 | Centrum or CWI or Corporation for National Research Initiatives or |
| 13 | CNRI not be used in advertising or publicity pertaining to |
| 14 | distribution of the software without specific, written prior |
| 15 | permission. |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame^] | 17 | While CWI is the initial source for this software, a modified version |
| 18 | is made available by the Corporation for National Research Initiatives |
| 19 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 22 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 23 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 24 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 25 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 26 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 27 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 28 | PERFORMANCE OF THIS SOFTWARE. |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 29 | |
| 30 | ******************************************************************/ |
| 31 | |
| 32 | |
| 33 | /* Cl objects */ |
| 34 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 35 | #define CLDEBUG |
| 36 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 37 | #include <stdarg.h> |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 38 | #include <cl.h> |
| 39 | #include "allobjects.h" |
| 40 | #include "modsupport.h" /* For getargs() etc. */ |
| 41 | #include "ceval.h" /* For call_object() */ |
| 42 | |
| 43 | typedef struct { |
| 44 | OB_HEAD |
| 45 | int ob_isCompressor; /* Compressor or Decompressor */ |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 46 | CL_Handle ob_compressorHdl; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 47 | int *ob_paramtypes; |
| 48 | int ob_nparams; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 49 | } clobject; |
| 50 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 51 | static object *ClError; /* exception cl.error */ |
| 52 | |
| 53 | static int error_handler_called = 0; |
| 54 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 55 | /* |
| 56 | * We want to use the function prototypes that are available in the C |
| 57 | * compiler on the SGI. Because of that, we need to declare the first |
| 58 | * argument of the compressor and decompressor methods as "object *", |
| 59 | * even though they are really "clobject *". Therefore we cast the |
| 60 | * argument to the proper type using this macro. |
| 61 | */ |
| 62 | #define SELF ((clobject *) self) |
| 63 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 64 | /******************************************************************** |
| 65 | Utility routines. |
| 66 | ********************************************************************/ |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 67 | static void |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 68 | cl_ErrorHandler(CL_Handle handle, int code, const char *fmt, ...) |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 69 | { |
| 70 | va_list ap; |
| 71 | char errbuf[BUFSIZ]; /* hopefully big enough */ |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 72 | char *p; |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 73 | |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 74 | if (err_occurred()) /* don't change existing error */ |
| 75 | return; |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 76 | error_handler_called = 1; |
| 77 | va_start(ap, fmt); |
| 78 | vsprintf(errbuf, fmt, ap); |
| 79 | va_end(ap); |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 80 | p = &errbuf[strlen(errbuf) - 1]; /* swat the line feed */ |
| 81 | if (*p == '\n') |
| 82 | *p = 0; |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 83 | err_setstr(ClError, errbuf); |
| 84 | } |
| 85 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 86 | /* |
| 87 | * This assumes that params are always in the range 0 to some maximum. |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 88 | */ |
| 89 | static int |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 90 | param_type_is_float(clobject *self, int param) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 91 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 92 | int bufferlength; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 93 | int ret; |
| 94 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 95 | if (self->ob_paramtypes == NULL) { |
| 96 | error_handler_called = 0; |
| 97 | bufferlength = clQueryParams(self->ob_compressorHdl, 0, 0); |
| 98 | if (error_handler_called) |
| 99 | return -1; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 100 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 101 | self->ob_paramtypes = NEW(int, bufferlength); |
| 102 | if (self->ob_paramtypes == NULL) |
| 103 | return -1; |
| 104 | self->ob_nparams = bufferlength / 2; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 105 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 106 | (void) clQueryParams(self->ob_compressorHdl, self->ob_paramtypes, bufferlength); |
| 107 | if (error_handler_called) { |
| 108 | DEL(self->ob_paramtypes); |
| 109 | self->ob_paramtypes = NULL; |
| 110 | return -1; |
| 111 | } |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 114 | if (param < 0 || param >= self->ob_nparams) |
| 115 | return -1; |
| 116 | |
| 117 | if (self->ob_paramtypes[param*2 + 1] == CL_FLOATING_ENUM_VALUE || |
| 118 | self->ob_paramtypes[param*2 + 1] == CL_FLOATING_RANGE_VALUE) |
| 119 | return 1; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 120 | else |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 121 | return 0; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /******************************************************************** |
| 125 | Single image compression/decompression. |
| 126 | ********************************************************************/ |
| 127 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 128 | cl_CompressImage(object *self, object *args) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 129 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 130 | int compressionScheme, width, height, originalFormat; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 131 | float compressionRatio; |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 132 | int frameBufferSize, compressedBufferSize; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 133 | char *frameBuffer; |
| 134 | object *compressedBuffer; |
| 135 | |
| 136 | if (!getargs(args, "(iiiifs#)", &compressionScheme, &width, &height, |
| 137 | &originalFormat, &compressionRatio, &frameBuffer, |
| 138 | &frameBufferSize)) |
| 139 | return NULL; |
| 140 | |
| 141 | retry: |
| 142 | compressedBuffer = newsizedstringobject(NULL, frameBufferSize); |
| 143 | if (compressedBuffer == NULL) |
| 144 | return NULL; |
| 145 | |
| 146 | compressedBufferSize = frameBufferSize; |
| 147 | error_handler_called = 0; |
| 148 | if (clCompressImage(compressionScheme, width, height, originalFormat, |
| 149 | compressionRatio, (void *) frameBuffer, |
| 150 | &compressedBufferSize, |
| 151 | (void *) getstringvalue(compressedBuffer)) |
| 152 | == FAILURE) { |
| 153 | DECREF(compressedBuffer); |
| 154 | if (!error_handler_called) |
| 155 | err_setstr(ClError, "clCompressImage failed"); |
| 156 | return NULL; |
| 157 | } |
| 158 | |
| 159 | if (compressedBufferSize > frameBufferSize) { |
| 160 | frameBufferSize = compressedBufferSize; |
| 161 | DECREF(compressedBuffer); |
| 162 | goto retry; |
| 163 | } |
| 164 | |
| 165 | if (compressedBufferSize < frameBufferSize) |
| 166 | if (resizestring(&compressedBuffer, compressedBufferSize)) |
| 167 | return NULL; |
| 168 | |
| 169 | return compressedBuffer; |
| 170 | } |
| 171 | |
| 172 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 173 | cl_DecompressImage(object *self, object *args) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 174 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 175 | int compressionScheme, width, height, originalFormat; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 176 | char *compressedBuffer; |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 177 | int compressedBufferSize, frameBufferSize; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 178 | object *frameBuffer; |
| 179 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 180 | if (!getargs(args, "(iiiis#)", &compressionScheme, &width, &height, |
| 181 | &originalFormat, &compressedBuffer, |
| 182 | &compressedBufferSize)) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 183 | return NULL; |
| 184 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 185 | frameBufferSize = width * height * CL_BytesPerPixel(originalFormat); |
| 186 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 187 | frameBuffer = newsizedstringobject(NULL, frameBufferSize); |
| 188 | if (frameBuffer == NULL) |
| 189 | return NULL; |
| 190 | |
| 191 | error_handler_called = 0; |
| 192 | if (clDecompressImage(compressionScheme, width, height, originalFormat, |
| 193 | compressedBufferSize, compressedBuffer, |
| 194 | (void *) getstringvalue(frameBuffer)) == FAILURE) { |
| 195 | DECREF(frameBuffer); |
| 196 | if (!error_handler_called) |
| 197 | err_setstr(ClError, "clDecompressImage failed"); |
| 198 | return NULL; |
| 199 | } |
| 200 | |
| 201 | return frameBuffer; |
| 202 | } |
| 203 | |
| 204 | /******************************************************************** |
| 205 | Sequential compression/decompression. |
| 206 | ********************************************************************/ |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 207 | #define CheckCompressor(self) if ((self)->ob_compressorHdl == NULL) { \ |
| 208 | err_setstr(RuntimeError, "(de)compressor not active"); \ |
| 209 | return NULL; \ |
| 210 | } |
| 211 | |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 212 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 213 | doClose(clobject *self, object *args, int (*close_func)(CL_Handle)) |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 214 | { |
| 215 | CheckCompressor(self); |
| 216 | |
| 217 | if (!getnoarg(args)) |
| 218 | return NULL; |
| 219 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 220 | error_handler_called = 0; |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 221 | if ((*close_func)(self->ob_compressorHdl) == FAILURE) { |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 222 | if (!error_handler_called) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 223 | err_setstr(ClError, "close failed"); |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 224 | return NULL; |
| 225 | } |
| 226 | |
| 227 | self->ob_compressorHdl = NULL; |
| 228 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 229 | if (self->ob_paramtypes) |
| 230 | DEL(self->ob_paramtypes); |
| 231 | self->ob_paramtypes = NULL; |
| 232 | |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 233 | INCREF(None); |
| 234 | return None; |
| 235 | } |
| 236 | |
| 237 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 238 | clm_CloseCompressor(object *self, object *args) |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 239 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 240 | return doClose(SELF, args, clCloseCompressor); |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 244 | clm_CloseDecompressor(object *self, object *args) |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 245 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 246 | return doClose(SELF, args, clCloseDecompressor); |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 250 | clm_Compress(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 251 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 252 | int numberOfFrames; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 253 | int frameBufferSize, compressedBufferSize, size; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 254 | char *frameBuffer; |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 255 | object *data; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 256 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 257 | CheckCompressor(SELF); |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 258 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 259 | if (!getargs(args, "(is#)", &numberOfFrames, &frameBuffer, &frameBufferSize)) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 260 | return NULL; |
| 261 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 262 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 263 | size = clGetParam(SELF->ob_compressorHdl, CL_COMPRESSED_BUFFER_SIZE); |
| 264 | compressedBufferSize = size; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 265 | if (error_handler_called) |
| 266 | return NULL; |
| 267 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 268 | data = newsizedstringobject(NULL, size); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 269 | if (data == NULL) |
| 270 | return NULL; |
| 271 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 272 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 273 | if (clCompress(SELF->ob_compressorHdl, numberOfFrames, |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 274 | (void *) frameBuffer, &compressedBufferSize, |
| 275 | (void *) getstringvalue(data)) == FAILURE) { |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 276 | DECREF(data); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 277 | if (!error_handler_called) |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 278 | err_setstr(ClError, "compress failed"); |
| 279 | return NULL; |
| 280 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 281 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 282 | if (compressedBufferSize < size) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 283 | if (resizestring(&data, compressedBufferSize)) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 284 | return NULL; |
| 285 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 286 | if (compressedBufferSize > size) { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 287 | /* we didn't get all "compressed" data */ |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 288 | DECREF(data); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 289 | err_setstr(ClError, "compressed data is more than fitted"); |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 290 | return NULL; |
| 291 | } |
| 292 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 293 | return data; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 294 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 295 | |
| 296 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 297 | clm_Decompress(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 298 | { |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 299 | object *data; |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 300 | int numberOfFrames; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 301 | char *compressedData; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 302 | int compressedDataSize, dataSize; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 303 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 304 | CheckCompressor(SELF); |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 305 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 306 | if (!getargs(args, "(is#)", &numberOfFrames, &compressedData, |
| 307 | &compressedDataSize)) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 308 | return NULL; |
| 309 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 310 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 311 | dataSize = clGetParam(SELF->ob_compressorHdl, CL_FRAME_BUFFER_SIZE); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 312 | if (error_handler_called) |
| 313 | return NULL; |
| 314 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 315 | data = newsizedstringobject(NULL, dataSize); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 316 | if (data == NULL) |
| 317 | return NULL; |
| 318 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 319 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 320 | if (clDecompress(SELF->ob_compressorHdl, numberOfFrames, |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 321 | compressedDataSize, (void *) compressedData, |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 322 | (void *) getstringvalue(data)) == FAILURE) { |
| 323 | DECREF(data); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 324 | if (!error_handler_called) |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 325 | err_setstr(ClError, "decompress failed"); |
| 326 | return NULL; |
| 327 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 328 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 329 | return data; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 333 | doParams(clobject *self, object *args, int (*func)(CL_Handle, int *, int), |
| 334 | int modified) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 335 | { |
| 336 | object *list, *v; |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 337 | int *PVbuffer; |
| 338 | int length; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 339 | int i; |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 340 | float number; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 341 | |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 342 | CheckCompressor(self); |
| 343 | |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 344 | if (!getargs(args, "O", &list)) |
| 345 | return NULL; |
| 346 | if (!is_listobject(list)) { |
| 347 | err_badarg(); |
| 348 | return NULL; |
| 349 | } |
| 350 | length = getlistsize(list); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 351 | PVbuffer = NEW(int, length); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 352 | if (PVbuffer == NULL) |
| 353 | return err_nomem(); |
| 354 | for (i = 0; i < length; i++) { |
| 355 | v = getlistitem(list, i); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 356 | if (is_floatobject(v)) { |
| 357 | number = getfloatvalue(v); |
| 358 | PVbuffer[i] = CL_TypeIsInt(number); |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 359 | } else if (is_intobject(v)) { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 360 | PVbuffer[i] = getintvalue(v); |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 361 | if ((i & 1) && |
| 362 | param_type_is_float(self, PVbuffer[i-1]) > 0) { |
| 363 | number = PVbuffer[i]; |
| 364 | PVbuffer[i] = CL_TypeIsInt(number); |
| 365 | } |
| 366 | } else { |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 367 | DEL(PVbuffer); |
| 368 | err_badarg(); |
| 369 | return NULL; |
| 370 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 373 | error_handler_called = 0; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 374 | (*func)(self->ob_compressorHdl, PVbuffer, length); |
Sjoerd Mullender | f64992e | 1993-08-03 15:11:36 +0000 | [diff] [blame] | 375 | if (error_handler_called) { |
| 376 | DEL(PVbuffer); |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 377 | return NULL; |
Sjoerd Mullender | f64992e | 1993-08-03 15:11:36 +0000 | [diff] [blame] | 378 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 379 | |
| 380 | if (modified) { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 381 | for (i = 0; i < length; i++) { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 382 | if ((i & 1) && |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 383 | param_type_is_float(self, PVbuffer[i-1]) > 0) { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 384 | number = CL_TypeIsFloat(PVbuffer[i]); |
| 385 | v = newfloatobject(number); |
| 386 | } else |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 387 | v = newintobject(PVbuffer[i]); |
| 388 | setlistitem(list, i, v); |
| 389 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | DEL(PVbuffer); |
| 393 | |
| 394 | INCREF(None); |
| 395 | return None; |
| 396 | } |
| 397 | |
| 398 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 399 | clm_GetParams(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 400 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 401 | return doParams(SELF, args, clGetParams, 1); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 405 | clm_SetParams(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 406 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 407 | return doParams(SELF, args, clSetParams, 0); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 411 | do_get(clobject *self, object *args, int (*func)(CL_Handle, int)) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 412 | { |
| 413 | int paramID, value; |
| 414 | float fvalue; |
| 415 | |
| 416 | CheckCompressor(self); |
| 417 | |
| 418 | if (!getargs(args, "i", ¶mID)) |
| 419 | return NULL; |
| 420 | |
| 421 | error_handler_called = 0; |
| 422 | value = (*func)(self->ob_compressorHdl, paramID); |
| 423 | if (error_handler_called) |
| 424 | return NULL; |
| 425 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 426 | if (param_type_is_float(self, paramID) > 0) { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 427 | fvalue = CL_TypeIsFloat(value); |
| 428 | return newfloatobject(fvalue); |
| 429 | } |
| 430 | |
| 431 | return newintobject(value); |
| 432 | } |
| 433 | |
| 434 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 435 | clm_GetParam(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 436 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 437 | return do_get(SELF, args, clGetParam); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 441 | clm_GetDefault(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 442 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 443 | return do_get(SELF, args, clGetDefault); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 447 | clm_SetParam(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 448 | { |
| 449 | int paramID, value; |
| 450 | float fvalue; |
| 451 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 452 | CheckCompressor(SELF); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 453 | |
| 454 | if (!getargs(args, "(ii)", ¶mID, &value)) { |
| 455 | err_clear(); |
| 456 | if (!getargs(args, "(if)", ¶mID, &fvalue)) { |
| 457 | err_clear(); |
| 458 | err_setstr(TypeError, "bad argument list (format '(ii)' or '(if)')"); |
| 459 | return NULL; |
| 460 | } |
| 461 | value = CL_TypeIsInt(fvalue); |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 462 | } else { |
| 463 | if (param_type_is_float(SELF, paramID) > 0) { |
| 464 | fvalue = value; |
| 465 | value = CL_TypeIsInt(fvalue); |
| 466 | } |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 467 | } |
| 468 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 469 | error_handler_called = 0; |
| 470 | value = clSetParam(SELF->ob_compressorHdl, paramID, value); |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 471 | if (error_handler_called) |
| 472 | return NULL; |
| 473 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 474 | if (param_type_is_float(SELF, paramID) > 0) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 475 | return newfloatobject(CL_TypeIsFloat(value)); |
| 476 | else |
| 477 | return newintobject(value); |
| 478 | } |
| 479 | |
| 480 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 481 | clm_GetParamID(object *self, object *args) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 482 | { |
| 483 | char *name; |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 484 | int value; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 485 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 486 | CheckCompressor(SELF); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 487 | |
| 488 | if (!getargs(args, "s", &name)) |
| 489 | return NULL; |
| 490 | |
| 491 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 492 | value = clGetParamID(SELF->ob_compressorHdl, name); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 493 | if (value == FAILURE) { |
| 494 | if (!error_handler_called) |
| 495 | err_setstr(ClError, "getparamid failed"); |
| 496 | return NULL; |
| 497 | } |
| 498 | |
| 499 | return newintobject(value); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 503 | clm_QueryParams(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 504 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 505 | int bufferlength; |
| 506 | int *PVbuffer; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 507 | object *list; |
| 508 | int i; |
| 509 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 510 | CheckCompressor(SELF); |
Sjoerd Mullender | 37f17b7 | 1992-09-25 10:28:20 +0000 | [diff] [blame] | 511 | |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 512 | if (!getnoarg(args)) |
| 513 | return NULL; |
| 514 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 515 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 516 | bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0); |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 517 | if (error_handler_called) |
| 518 | return NULL; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 519 | |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 520 | PVbuffer = NEW(int, bufferlength); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 521 | if (PVbuffer == NULL) |
| 522 | return err_nomem(); |
| 523 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 524 | bufferlength = clQueryParams(SELF->ob_compressorHdl, PVbuffer, |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 525 | bufferlength); |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 526 | if (error_handler_called) { |
| 527 | DEL(PVbuffer); |
| 528 | return NULL; |
| 529 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 530 | |
| 531 | list = newlistobject(bufferlength); |
| 532 | if (list == NULL) { |
| 533 | DEL(PVbuffer); |
| 534 | return NULL; |
| 535 | } |
| 536 | |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 537 | for (i = 0; i < bufferlength; i++) { |
| 538 | if (i & 1) |
| 539 | setlistitem(list, i, newintobject(PVbuffer[i])); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 540 | else if (PVbuffer[i] == 0) { |
| 541 | INCREF(None); |
| 542 | setlistitem(list, i, None); |
| 543 | } else |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 544 | setlistitem(list, i, newstringobject((char *) PVbuffer[i])); |
| 545 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 546 | |
| 547 | DEL(PVbuffer); |
| 548 | |
| 549 | return list; |
| 550 | } |
| 551 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 552 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 553 | clm_GetMinMax(object *self, object *args) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 554 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 555 | int param, min, max; |
| 556 | float fmin, fmax; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 557 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 558 | CheckCompressor(SELF); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 559 | |
| 560 | if (!getargs(args, "i", ¶m)) |
| 561 | return NULL; |
| 562 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 563 | clGetMinMax(SELF->ob_compressorHdl, param, &min, &max); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 564 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 565 | if (param_type_is_float(SELF, param) > 0) { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 566 | fmin = CL_TypeIsFloat(min); |
| 567 | fmax = CL_TypeIsFloat(max); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 568 | return mkvalue("(ff)", fmin, fmax); |
| 569 | } |
| 570 | |
| 571 | return mkvalue("(ii)", min, max); |
| 572 | } |
| 573 | |
| 574 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 575 | clm_GetName(object *self, object *args) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 576 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 577 | int param; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 578 | char *name; |
| 579 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 580 | CheckCompressor(SELF); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 581 | |
| 582 | if (!getargs(args, "i", ¶m)) |
| 583 | return NULL; |
| 584 | |
| 585 | error_handler_called = 0; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 586 | name = clGetName(SELF->ob_compressorHdl, param); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 587 | if (name == NULL || error_handler_called) { |
| 588 | if (!error_handler_called) |
| 589 | err_setstr(ClError, "getname failed"); |
| 590 | return NULL; |
| 591 | } |
| 592 | |
| 593 | return newstringobject(name); |
| 594 | } |
| 595 | |
| 596 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 597 | clm_QuerySchemeFromHandle(object *self, object *args) |
| 598 | { |
| 599 | CheckCompressor(SELF); |
| 600 | |
| 601 | if (!getnoarg(args)) |
| 602 | return NULL; |
| 603 | |
| 604 | return newintobject(clQuerySchemeFromHandle(SELF->ob_compressorHdl)); |
| 605 | } |
| 606 | |
| 607 | static object * |
| 608 | clm_ReadHeader(object *self, object *args) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 609 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 610 | char *header; |
| 611 | int headerSize; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 612 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 613 | CheckCompressor(SELF); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 614 | |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 615 | if (!getargs(args, "s#", &header, &headerSize)) |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 616 | return NULL; |
| 617 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 618 | return newintobject(clReadHeader(SELF->ob_compressorHdl, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 619 | headerSize, header)); |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 620 | } |
| 621 | |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 622 | static struct methodlist compressor_methods[] = { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 623 | {"close", clm_CloseCompressor}, /* alias */ |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 624 | {"CloseCompressor", clm_CloseCompressor}, |
| 625 | {"Compress", clm_Compress}, |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 626 | {"GetDefault", clm_GetDefault}, |
| 627 | {"GetMinMax", clm_GetMinMax}, |
| 628 | {"GetName", clm_GetName}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 629 | {"GetParam", clm_GetParam}, |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 630 | {"GetParamID", clm_GetParamID}, |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 631 | {"GetParams", clm_GetParams}, |
| 632 | {"QueryParams", clm_QueryParams}, |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 633 | {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 634 | {"SetParam", clm_SetParam}, |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 635 | {"SetParams", clm_SetParams}, |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 636 | {NULL, NULL} /* sentinel */ |
| 637 | }; |
| 638 | |
| 639 | static struct methodlist decompressor_methods[] = { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 640 | {"close", clm_CloseDecompressor}, /* alias */ |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 641 | {"CloseDecompressor", clm_CloseDecompressor}, |
| 642 | {"Decompress", clm_Decompress}, |
| 643 | {"GetDefault", clm_GetDefault}, |
| 644 | {"GetMinMax", clm_GetMinMax}, |
| 645 | {"GetName", clm_GetName}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 646 | {"GetParam", clm_GetParam}, |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 647 | {"GetParamID", clm_GetParamID}, |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 648 | {"GetParams", clm_GetParams}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 649 | {"ReadHeader", clm_ReadHeader}, |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 650 | {"QueryParams", clm_QueryParams}, |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 651 | {"QuerySchemeFromHandle",clm_QuerySchemeFromHandle}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 652 | {"SetParam", clm_SetParam}, |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 653 | {"SetParams", clm_SetParams}, |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 654 | {NULL, NULL} /* sentinel */ |
| 655 | }; |
| 656 | |
| 657 | static void |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 658 | cl_dealloc(object *self) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 659 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 660 | if (SELF->ob_compressorHdl) { |
| 661 | if (SELF->ob_isCompressor) |
| 662 | clCloseCompressor(SELF->ob_compressorHdl); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 663 | else |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 664 | clCloseDecompressor(SELF->ob_compressorHdl); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 665 | } |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 666 | DEL(self); |
| 667 | } |
| 668 | |
| 669 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 670 | cl_getattr(object *self, char *name) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 671 | { |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 672 | if (SELF->ob_isCompressor) |
| 673 | return findmethod(compressor_methods, self, name); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 674 | else |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 675 | return findmethod(decompressor_methods, self, name); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | static typeobject Cltype = { |
| 679 | OB_HEAD_INIT(&Typetype) |
| 680 | 0, /*ob_size*/ |
| 681 | "cl", /*tp_name*/ |
| 682 | sizeof(clobject), /*tp_size*/ |
| 683 | 0, /*tp_itemsize*/ |
| 684 | /* methods */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 685 | (destructor)cl_dealloc, /*tp_dealloc*/ |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 686 | 0, /*tp_print*/ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 687 | (getattrfunc)cl_getattr, /*tp_getattr*/ |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 688 | 0, /*tp_setattr*/ |
| 689 | 0, /*tp_compare*/ |
| 690 | 0, /*tp_repr*/ |
| 691 | 0, /*tp_as_number*/ |
| 692 | 0, /*tp_as_sequence*/ |
| 693 | 0, /*tp_as_mapping*/ |
| 694 | }; |
| 695 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 696 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 697 | doOpen(object *self, object *args, int (*open_func)(int, CL_Handle *), |
| 698 | int iscompressor) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 699 | { |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 700 | int scheme; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 701 | clobject *new; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 702 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 703 | if (!getargs(args, "i", &scheme)) |
| 704 | return NULL; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 705 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 706 | new = NEWOBJ(clobject, &Cltype); |
| 707 | if (new == NULL) |
| 708 | return NULL; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 709 | |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 710 | new->ob_compressorHdl = NULL; |
| 711 | new->ob_isCompressor = iscompressor; |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 712 | new->ob_paramtypes = NULL; |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 713 | |
| 714 | error_handler_called = 0; |
| 715 | if ((*open_func)(scheme, &new->ob_compressorHdl) == FAILURE) { |
| 716 | DECREF(new); |
| 717 | if (!error_handler_called) |
| 718 | err_setstr(ClError, "Open(De)Compressor failed"); |
| 719 | return NULL; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 720 | } |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 721 | return (object *)new; |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 725 | cl_OpenCompressor(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 726 | { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 727 | return doOpen(self, args, clOpenCompressor, 1); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 731 | cl_OpenDecompressor(object *self, object *args) |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 732 | { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 733 | return doOpen(self, args, clOpenDecompressor, 0); |
Sjoerd Mullender | 384f248 | 1992-09-29 16:43:43 +0000 | [diff] [blame] | 734 | } |
| 735 | |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 736 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 737 | cl_QueryScheme(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 738 | { |
| 739 | char *header; |
| 740 | int headerlen; |
| 741 | int scheme; |
| 742 | |
| 743 | if (!getargs(args, "s#", &header, &headerlen)) |
| 744 | return NULL; |
| 745 | |
| 746 | scheme = clQueryScheme(header); |
| 747 | if (scheme < 0) { |
| 748 | err_setstr(ClError, "unknown compression scheme"); |
| 749 | return NULL; |
| 750 | } |
| 751 | |
| 752 | return newintobject(scheme); |
| 753 | } |
| 754 | |
| 755 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 756 | cl_QueryMaxHeaderSize(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 757 | { |
| 758 | int scheme; |
| 759 | |
| 760 | if (!getargs(args, "i", &scheme)) |
| 761 | return NULL; |
| 762 | |
| 763 | return newintobject(clQueryMaxHeaderSize(scheme)); |
| 764 | } |
| 765 | |
| 766 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 767 | cl_QueryAlgorithms(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 768 | { |
| 769 | int algorithmMediaType; |
| 770 | int bufferlength; |
| 771 | int *PVbuffer; |
| 772 | object *list; |
| 773 | int i; |
| 774 | |
| 775 | if (!getargs(args, "i", &algorithmMediaType)) |
| 776 | return NULL; |
| 777 | |
| 778 | error_handler_called = 0; |
| 779 | bufferlength = clQueryAlgorithms(algorithmMediaType, 0, 0); |
| 780 | if (error_handler_called) |
| 781 | return NULL; |
| 782 | |
| 783 | PVbuffer = NEW(int, bufferlength); |
| 784 | if (PVbuffer == NULL) |
| 785 | return err_nomem(); |
| 786 | |
| 787 | bufferlength = clQueryAlgorithms(algorithmMediaType, PVbuffer, |
| 788 | bufferlength); |
| 789 | if (error_handler_called) { |
| 790 | DEL(PVbuffer); |
| 791 | return NULL; |
| 792 | } |
| 793 | |
| 794 | list = newlistobject(bufferlength); |
| 795 | if (list == NULL) { |
| 796 | DEL(PVbuffer); |
| 797 | return NULL; |
| 798 | } |
| 799 | |
| 800 | for (i = 0; i < bufferlength; i++) { |
| 801 | if (i & 1) |
| 802 | setlistitem(list, i, newintobject(PVbuffer[i])); |
| 803 | else if (PVbuffer[i] == 0) { |
| 804 | INCREF(None); |
| 805 | setlistitem(list, i, None); |
| 806 | } else |
| 807 | setlistitem(list, i, newstringobject((char *) PVbuffer[i])); |
| 808 | } |
| 809 | |
| 810 | DEL(PVbuffer); |
| 811 | |
| 812 | return list; |
| 813 | } |
| 814 | |
| 815 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 816 | cl_QuerySchemeFromName(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 817 | { |
| 818 | int algorithmMediaType; |
| 819 | char *name; |
| 820 | int scheme; |
| 821 | |
| 822 | if (!getargs(args, "(is)", &algorithmMediaType, &name)) |
| 823 | return NULL; |
| 824 | |
| 825 | error_handler_called = 0; |
| 826 | scheme = clQuerySchemeFromName(algorithmMediaType, name); |
| 827 | if (error_handler_called) { |
| 828 | err_setstr(ClError, "unknown compression scheme"); |
| 829 | return NULL; |
| 830 | } |
| 831 | |
| 832 | return newintobject(scheme); |
| 833 | } |
| 834 | |
| 835 | static object * |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 836 | cl_GetAlgorithmName(object *self, object *args) |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 837 | { |
| 838 | int scheme; |
| 839 | char *name; |
| 840 | |
| 841 | if (!getargs(args, "i", &scheme)) |
| 842 | return NULL; |
| 843 | |
| 844 | name = clGetAlgorithmName(scheme); |
| 845 | if (name == 0) { |
| 846 | err_setstr(ClError, "unknown compression scheme"); |
| 847 | return NULL; |
| 848 | } |
| 849 | |
| 850 | return newstringobject(name); |
| 851 | } |
| 852 | |
Sjoerd Mullender | 22e44cd | 1993-02-17 09:11:14 +0000 | [diff] [blame] | 853 | static object * |
| 854 | do_set(object *self, object *args, int (*func)(int, int, int)) |
| 855 | { |
| 856 | int scheme, paramID, value; |
| 857 | float fvalue; |
| 858 | int is_float = 0; |
| 859 | |
| 860 | if (!getargs(args, "(iii)", &scheme, ¶mID, &value)) { |
| 861 | err_clear(); |
| 862 | if (!getargs(args, "(iif)", &scheme, ¶mID, &fvalue)) { |
| 863 | err_clear(); |
| 864 | err_setstr(TypeError, "bad argument list (format '(iii)' or '(iif)')"); |
| 865 | return NULL; |
| 866 | } |
| 867 | value = CL_TypeIsInt(fvalue); |
| 868 | is_float = 1; |
| 869 | } else { |
| 870 | /* check some parameters which we know to be floats */ |
| 871 | switch (scheme) { |
| 872 | case CL_COMPRESSION_RATIO: |
| 873 | case CL_SPEED: |
| 874 | fvalue = value; |
| 875 | value = CL_TypeIsInt(fvalue); |
| 876 | is_float = 1; |
| 877 | break; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | error_handler_called = 0; |
| 882 | value = (*func)(scheme, paramID, value); |
| 883 | if (error_handler_called) |
| 884 | return NULL; |
| 885 | |
| 886 | if (is_float) |
| 887 | return newfloatobject(CL_TypeIsFloat(value)); |
| 888 | else |
| 889 | return newintobject(value); |
| 890 | } |
| 891 | |
| 892 | static object * |
| 893 | cl_SetDefault(object *self, object *args) |
| 894 | { |
| 895 | return do_set(self, args, clSetDefault); |
| 896 | } |
| 897 | |
| 898 | static object * |
| 899 | cl_SetMin(object *self, object *args) |
| 900 | { |
| 901 | return do_set(self, args, clSetMin); |
| 902 | } |
| 903 | |
| 904 | static object * |
| 905 | cl_SetMax(object *self, object *args) |
| 906 | { |
| 907 | return do_set(self, args, clSetMax); |
| 908 | } |
| 909 | |
Sjoerd Mullender | 3db845b | 1995-05-17 11:16:52 +0000 | [diff] [blame] | 910 | #define func(name, type) \ |
| 911 | static object *cl_##name(object *self, object *args) \ |
| 912 | { \ |
| 913 | int x; \ |
| 914 | if (!getargs(args, "i", &x)) return NULL; \ |
| 915 | return new##type##object(CL_##name(x)); \ |
| 916 | } |
| 917 | |
| 918 | #define func2(name, type) \ |
| 919 | static object *cl_##name(object *self, object *args) \ |
| 920 | { \ |
| 921 | int a1, a2; \ |
| 922 | if (!getargs(args, "(ii)", &a1, &a2)) return NULL; \ |
| 923 | return new##type##object(CL_##name(a1, a2)); \ |
| 924 | } |
| 925 | |
| 926 | func(BytesPerSample,int) |
| 927 | func(BytesPerPixel,int) |
| 928 | func(AudioFormatName,string) |
| 929 | func(VideoFormatName,string) |
| 930 | func(AlgorithmNumber,int) |
| 931 | func(AlgorithmType,int) |
| 932 | func2(Algorithm,int) |
| 933 | func(ParamNumber,int) |
| 934 | func(ParamType,int) |
| 935 | func2(ParamID,int) |
| 936 | |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 937 | #ifdef CLDEBUG |
| 938 | static object * |
| 939 | cvt_type(object *self, object *args) |
| 940 | { |
| 941 | int number; |
| 942 | float fnumber; |
| 943 | |
| 944 | if (getargs(args, "i", &number)) |
| 945 | return newfloatobject(CL_TypeIsFloat(number)); |
| 946 | else { |
| 947 | err_clear(); |
| 948 | if (getargs(args, "f", &fnumber)) |
| 949 | return newintobject(CL_TypeIsInt(fnumber)); |
| 950 | return NULL; |
| 951 | } |
| 952 | } |
| 953 | #endif |
| 954 | |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 955 | static struct methodlist cl_methods[] = { |
Sjoerd Mullender | 8dd054d | 1992-12-14 13:17:29 +0000 | [diff] [blame] | 956 | {"CompressImage", cl_CompressImage}, |
| 957 | {"DecompressImage", cl_DecompressImage}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 958 | {"GetAlgorithmName", cl_GetAlgorithmName}, |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 959 | {"OpenCompressor", cl_OpenCompressor}, |
| 960 | {"OpenDecompressor", cl_OpenDecompressor}, |
Sjoerd Mullender | 3a99727 | 1993-02-04 16:43:28 +0000 | [diff] [blame] | 961 | {"QueryAlgorithms", cl_QueryAlgorithms}, |
| 962 | {"QueryMaxHeaderSize", cl_QueryMaxHeaderSize}, |
| 963 | {"QueryScheme", cl_QueryScheme}, |
| 964 | {"QuerySchemeFromName", cl_QuerySchemeFromName}, |
Sjoerd Mullender | 22e44cd | 1993-02-17 09:11:14 +0000 | [diff] [blame] | 965 | {"SetDefault", cl_SetDefault}, |
| 966 | {"SetMax", cl_SetMax}, |
| 967 | {"SetMin", cl_SetMin}, |
Sjoerd Mullender | 3db845b | 1995-05-17 11:16:52 +0000 | [diff] [blame] | 968 | {"BytesPerSample", cl_BytesPerSample}, |
| 969 | {"BytesPerPixel", cl_BytesPerPixel}, |
| 970 | {"AudioFormatName", cl_AudioFormatName}, |
| 971 | {"VideoFormatName", cl_VideoFormatName}, |
| 972 | {"AlgorithmNumber", cl_AlgorithmNumber}, |
| 973 | {"AlgorithmType", cl_AlgorithmType}, |
| 974 | {"Algorithm", cl_Algorithm}, |
| 975 | {"ParamNumber", cl_ParamNumber}, |
| 976 | {"ParamType", cl_ParamType}, |
| 977 | {"ParamID", cl_ParamID}, |
Sjoerd Mullender | 4e2a427 | 1993-02-16 11:55:17 +0000 | [diff] [blame] | 978 | #ifdef CLDEBUG |
| 979 | {"cvt_type", cvt_type}, |
| 980 | #endif |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 981 | {NULL, NULL} /* Sentinel */ |
| 982 | }; |
| 983 | |
Sjoerd Mullender | 3db845b | 1995-05-17 11:16:52 +0000 | [diff] [blame] | 984 | #ifdef CL_JPEG_SOFTWARE |
| 985 | #define IRIX_5_3_LIBRARY |
| 986 | #endif |
| 987 | |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 988 | void |
| 989 | initcl() |
| 990 | { |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 991 | object *m, *d; |
| 992 | |
| 993 | m = initmodule("cl", cl_methods); |
| 994 | d = getmoduledict(m); |
| 995 | |
| 996 | ClError = newstringobject("cl.error"); |
Sjoerd Mullender | 3db845b | 1995-05-17 11:16:52 +0000 | [diff] [blame] | 997 | (void) dictinsert(d, "error", ClError); |
| 998 | |
| 999 | (void) dictinsert(d, "MAX_NUMBER_OF_ORIGINAL_FORMATS", |
| 1000 | newintobject(CL_MAX_NUMBER_OF_ORIGINAL_FORMATS)); |
| 1001 | (void) dictinsert(d, "MONO", newintobject(CL_MONO)); |
| 1002 | (void) dictinsert(d, "STEREO_INTERLEAVED", |
| 1003 | newintobject(CL_STEREO_INTERLEAVED)); |
| 1004 | (void) dictinsert(d, "RGB", newintobject(CL_RGB)); |
| 1005 | (void) dictinsert(d, "RGBX", newintobject(CL_RGBX)); |
| 1006 | (void) dictinsert(d, "RGBA", newintobject(CL_RGBA)); |
| 1007 | (void) dictinsert(d, "RGB332", newintobject(CL_RGB332)); |
| 1008 | (void) dictinsert(d, "GRAYSCALE", newintobject(CL_GRAYSCALE)); |
| 1009 | (void) dictinsert(d, "Y", newintobject(CL_Y)); |
| 1010 | (void) dictinsert(d, "YUV", newintobject(CL_YUV)); |
| 1011 | (void) dictinsert(d, "YCbCr", newintobject(CL_YCbCr)); |
| 1012 | (void) dictinsert(d, "YUV422", newintobject(CL_YUV422)); |
| 1013 | (void) dictinsert(d, "YCbCr422", newintobject(CL_YCbCr422)); |
| 1014 | (void) dictinsert(d, "YUV422HC", newintobject(CL_YUV422HC)); |
| 1015 | (void) dictinsert(d, "YCbCr422HC", newintobject(CL_YCbCr422HC)); |
| 1016 | (void) dictinsert(d, "YUV422DC", newintobject(CL_YUV422DC)); |
| 1017 | (void) dictinsert(d, "YCbCr422DC", newintobject(CL_YCbCr422DC)); |
| 1018 | (void) dictinsert(d, "RGB8", newintobject(CL_RGB8)); |
| 1019 | (void) dictinsert(d, "BEST_FIT", newintobject(CL_BEST_FIT)); |
| 1020 | (void) dictinsert(d, "MAX_NUMBER_OF_AUDIO_ALGORITHMS", |
| 1021 | newintobject(CL_MAX_NUMBER_OF_AUDIO_ALGORITHMS)); |
| 1022 | (void) dictinsert(d, "MAX_NUMBER_OF_VIDEO_ALGORITHMS", |
| 1023 | newintobject(CL_MAX_NUMBER_OF_VIDEO_ALGORITHMS)); |
| 1024 | (void) dictinsert(d, "AUDIO", newintobject(CL_AUDIO)); |
| 1025 | (void) dictinsert(d, "VIDEO", newintobject(CL_VIDEO)); |
| 1026 | (void) dictinsert(d, "UNKNOWN_SCHEME", |
| 1027 | newintobject(CL_UNKNOWN_SCHEME)); |
| 1028 | (void) dictinsert(d, "UNCOMPRESSED_AUDIO", |
| 1029 | newintobject(CL_UNCOMPRESSED_AUDIO)); |
| 1030 | (void) dictinsert(d, "G711_ULAW", newintobject(CL_G711_ULAW)); |
| 1031 | (void) dictinsert(d, "ULAW", newintobject(CL_ULAW)); |
| 1032 | (void) dictinsert(d, "G711_ALAW", newintobject(CL_G711_ALAW)); |
| 1033 | (void) dictinsert(d, "ALAW", newintobject(CL_ALAW)); |
| 1034 | (void) dictinsert(d, "AWARE_MPEG_AUDIO", |
| 1035 | newintobject(CL_AWARE_MPEG_AUDIO)); |
| 1036 | (void) dictinsert(d, "AWARE_MULTIRATE", |
| 1037 | newintobject(CL_AWARE_MULTIRATE)); |
| 1038 | (void) dictinsert(d, "UNCOMPRESSED", newintobject(CL_UNCOMPRESSED)); |
| 1039 | (void) dictinsert(d, "UNCOMPRESSED_VIDEO", |
| 1040 | newintobject(CL_UNCOMPRESSED_VIDEO)); |
| 1041 | (void) dictinsert(d, "RLE", newintobject(CL_RLE)); |
| 1042 | (void) dictinsert(d, "JPEG", newintobject(CL_JPEG)); |
| 1043 | #ifdef IRIX_5_3_LIBRARY |
| 1044 | (void) dictinsert(d, "JPEG_SOFTWARE", newintobject(CL_JPEG_SOFTWARE)); |
| 1045 | #endif |
| 1046 | (void) dictinsert(d, "MPEG_VIDEO", newintobject(CL_MPEG_VIDEO)); |
| 1047 | (void) dictinsert(d, "MVC1", newintobject(CL_MVC1)); |
| 1048 | (void) dictinsert(d, "RTR", newintobject(CL_RTR)); |
| 1049 | (void) dictinsert(d, "RTR1", newintobject(CL_RTR1)); |
| 1050 | (void) dictinsert(d, "HDCC", newintobject(CL_HDCC)); |
| 1051 | (void) dictinsert(d, "MVC2", newintobject(CL_MVC2)); |
| 1052 | (void) dictinsert(d, "RLE24", newintobject(CL_RLE24)); |
| 1053 | (void) dictinsert(d, "MAX_NUMBER_OF_PARAMS", |
| 1054 | newintobject(CL_MAX_NUMBER_OF_PARAMS)); |
| 1055 | (void) dictinsert(d, "IMAGE_WIDTH", newintobject(CL_IMAGE_WIDTH)); |
| 1056 | (void) dictinsert(d, "IMAGE_HEIGHT", newintobject(CL_IMAGE_HEIGHT)); |
| 1057 | (void) dictinsert(d, "ORIGINAL_FORMAT", |
| 1058 | newintobject(CL_ORIGINAL_FORMAT)); |
| 1059 | (void) dictinsert(d, "INTERNAL_FORMAT", |
| 1060 | newintobject(CL_INTERNAL_FORMAT)); |
| 1061 | (void) dictinsert(d, "COMPONENTS", newintobject(CL_COMPONENTS)); |
| 1062 | (void) dictinsert(d, "BITS_PER_COMPONENT", |
| 1063 | newintobject(CL_BITS_PER_COMPONENT)); |
| 1064 | (void) dictinsert(d, "FRAME_RATE", newintobject(CL_FRAME_RATE)); |
| 1065 | (void) dictinsert(d, "COMPRESSION_RATIO", |
| 1066 | newintobject(CL_COMPRESSION_RATIO)); |
| 1067 | (void) dictinsert(d, "EXACT_COMPRESSION_RATIO", |
| 1068 | newintobject(CL_EXACT_COMPRESSION_RATIO)); |
| 1069 | (void) dictinsert(d, "FRAME_BUFFER_SIZE", |
| 1070 | newintobject(CL_FRAME_BUFFER_SIZE)); |
| 1071 | (void) dictinsert(d, "COMPRESSED_BUFFER_SIZE", |
| 1072 | newintobject(CL_COMPRESSED_BUFFER_SIZE)); |
| 1073 | (void) dictinsert(d, "BLOCK_SIZE", newintobject(CL_BLOCK_SIZE)); |
| 1074 | (void) dictinsert(d, "PREROLL", newintobject(CL_PREROLL)); |
| 1075 | (void) dictinsert(d, "FRAME_TYPE", newintobject(CL_FRAME_TYPE)); |
| 1076 | (void) dictinsert(d, "ALGORITHM_ID", newintobject(CL_ALGORITHM_ID)); |
| 1077 | (void) dictinsert(d, "ALGORITHM_VERSION", |
| 1078 | newintobject(CL_ALGORITHM_VERSION)); |
| 1079 | (void) dictinsert(d, "ORIENTATION", newintobject(CL_ORIENTATION)); |
| 1080 | (void) dictinsert(d, "NUMBER_OF_FRAMES", |
| 1081 | newintobject(CL_NUMBER_OF_FRAMES)); |
| 1082 | (void) dictinsert(d, "SPEED", newintobject(CL_SPEED)); |
| 1083 | (void) dictinsert(d, "LAST_FRAME_INDEX", |
| 1084 | newintobject(CL_LAST_FRAME_INDEX)); |
| 1085 | #ifdef IRIX_5_3_LIBRARY |
| 1086 | (void) dictinsert(d, "ENABLE_IMAGEINFO", |
| 1087 | newintobject(CL_ENABLE_IMAGEINFO)); |
| 1088 | (void) dictinsert(d, "INTERNAL_IMAGE_WIDTH", |
| 1089 | newintobject(CL_INTERNAL_IMAGE_WIDTH)); |
| 1090 | (void) dictinsert(d, "INTERNAL_IMAGE_HEIGHT", |
| 1091 | newintobject(CL_INTERNAL_IMAGE_HEIGHT)); |
| 1092 | #endif |
| 1093 | (void) dictinsert(d, "NUMBER_OF_PARAMS", |
| 1094 | newintobject(CL_NUMBER_OF_PARAMS)); |
| 1095 | #ifdef IRIX_5_3_LIBRARY |
| 1096 | (void) dictinsert(d, "MVC2_LUMA_THRESHOLD", |
| 1097 | newintobject(CL_MVC2_LUMA_THRESHOLD)); |
| 1098 | (void) dictinsert(d, "MVC2_CHROMA_THRESHOLD", |
| 1099 | newintobject(CL_MVC2_CHROMA_THRESHOLD)); |
| 1100 | (void) dictinsert(d, "MVC2_EDGE_THRESHOLD", |
| 1101 | newintobject(CL_MVC2_EDGE_THRESHOLD)); |
| 1102 | (void) dictinsert(d, "MVC2_BLENDING", newintobject(CL_MVC2_BLENDING)); |
| 1103 | (void) dictinsert(d, "MVC2_BLENDING_OFF", |
| 1104 | newintobject(CL_MVC2_BLENDING_OFF)); |
| 1105 | (void) dictinsert(d, "MVC2_BLENDING_ON", |
| 1106 | newintobject(CL_MVC2_BLENDING_ON)); |
| 1107 | (void) dictinsert(d, "JPEG_QUALITY_FACTOR", |
| 1108 | newintobject(CL_JPEG_QUALITY_FACTOR)); |
| 1109 | (void) dictinsert(d, "JPEG_STREAM_HEADERS", |
| 1110 | newintobject(CL_JPEG_STREAM_HEADERS)); |
| 1111 | (void) dictinsert(d, "JPEG_QUANTIZATION_TABLES", |
| 1112 | newintobject(CL_JPEG_QUANTIZATION_TABLES)); |
| 1113 | (void) dictinsert(d, "JPEG_NUM_PARAMS", |
| 1114 | newintobject(CL_JPEG_NUM_PARAMS)); |
| 1115 | (void) dictinsert(d, "RTR_QUALITY_LEVEL", |
| 1116 | newintobject(CL_RTR_QUALITY_LEVEL)); |
| 1117 | (void) dictinsert(d, "HDCC_TILE_THRESHOLD", |
| 1118 | newintobject(CL_HDCC_TILE_THRESHOLD)); |
| 1119 | (void) dictinsert(d, "HDCC_SAMPLES_PER_TILE", |
| 1120 | newintobject(CL_HDCC_SAMPLES_PER_TILE)); |
| 1121 | #endif |
| 1122 | (void) dictinsert(d, "END_OF_SEQUENCE", |
| 1123 | newintobject(CL_END_OF_SEQUENCE)); |
| 1124 | (void) dictinsert(d, "CHANNEL_POLICY", |
| 1125 | newintobject(CL_CHANNEL_POLICY)); |
| 1126 | (void) dictinsert(d, "NOISE_MARGIN", newintobject(CL_NOISE_MARGIN)); |
| 1127 | (void) dictinsert(d, "BITRATE_POLICY", |
| 1128 | newintobject(CL_BITRATE_POLICY)); |
| 1129 | (void) dictinsert(d, "BITRATE_TARGET", |
| 1130 | newintobject(CL_BITRATE_TARGET)); |
| 1131 | (void) dictinsert(d, "LAYER", newintobject(CL_LAYER)); |
| 1132 | (void) dictinsert(d, "ENUM_VALUE", newintobject(CL_ENUM_VALUE)); |
| 1133 | (void) dictinsert(d, "RANGE_VALUE", newintobject(CL_RANGE_VALUE)); |
| 1134 | (void) dictinsert(d, "FLOATING_ENUM_VALUE", |
| 1135 | newintobject(CL_FLOATING_ENUM_VALUE)); |
| 1136 | (void) dictinsert(d, "FLOATING_RANGE_VALUE", |
| 1137 | newintobject(CL_FLOATING_RANGE_VALUE)); |
| 1138 | (void) dictinsert(d, "DECOMPRESSOR", newintobject(CL_DECOMPRESSOR)); |
| 1139 | (void) dictinsert(d, "COMPRESSOR", newintobject(CL_COMPRESSOR)); |
| 1140 | (void) dictinsert(d, "CODEC", newintobject(CL_CODEC)); |
| 1141 | (void) dictinsert(d, "NONE", newintobject(CL_NONE)); |
| 1142 | #ifdef IRIX_5_3_LIBRARY |
| 1143 | (void) dictinsert(d, "BUF_FRAME", newintobject(CL_BUF_FRAME)); |
| 1144 | (void) dictinsert(d, "BUF_DATA", newintobject(CL_BUF_DATA)); |
| 1145 | #endif |
| 1146 | #ifdef CL_FRAME |
| 1147 | (void) dictinsert(d, "FRAME", newintobject(CL_FRAME)); |
| 1148 | (void) dictinsert(d, "DATA", newintobject(CL_DATA)); |
| 1149 | #endif |
| 1150 | (void) dictinsert(d, "NONE", newintobject(CL_NONE)); |
| 1151 | (void) dictinsert(d, "KEYFRAME", newintobject(CL_KEYFRAME)); |
| 1152 | (void) dictinsert(d, "INTRA", newintobject(CL_INTRA)); |
| 1153 | (void) dictinsert(d, "PREDICTED", newintobject(CL_PREDICTED)); |
| 1154 | (void) dictinsert(d, "BIDIRECTIONAL", newintobject(CL_BIDIRECTIONAL)); |
| 1155 | (void) dictinsert(d, "TOP_DOWN", newintobject(CL_TOP_DOWN)); |
| 1156 | (void) dictinsert(d, "BOTTOM_UP", newintobject(CL_BOTTOM_UP)); |
| 1157 | #ifdef IRIX_5_3_LIBRARY |
| 1158 | (void) dictinsert(d, "CONTINUOUS_BLOCK", |
| 1159 | newintobject(CL_CONTINUOUS_BLOCK)); |
| 1160 | (void) dictinsert(d, "CONTINUOUS_NONBLOCK", |
| 1161 | newintobject(CL_CONTINUOUS_NONBLOCK)); |
| 1162 | (void) dictinsert(d, "EXTERNAL_DEVICE", |
| 1163 | newintobject((long)CL_EXTERNAL_DEVICE)); |
| 1164 | #endif |
| 1165 | (void) dictinsert(d, "AWCMP_STEREO", newintobject(AWCMP_STEREO)); |
| 1166 | (void) dictinsert(d, "AWCMP_JOINT_STEREO", |
| 1167 | newintobject(AWCMP_JOINT_STEREO)); |
| 1168 | (void) dictinsert(d, "AWCMP_INDEPENDENT", |
| 1169 | newintobject(AWCMP_INDEPENDENT)); |
| 1170 | (void) dictinsert(d, "AWCMP_FIXED_RATE", |
| 1171 | newintobject(AWCMP_FIXED_RATE)); |
| 1172 | (void) dictinsert(d, "AWCMP_CONST_QUAL", |
| 1173 | newintobject(AWCMP_CONST_QUAL)); |
| 1174 | (void) dictinsert(d, "AWCMP_LOSSLESS", newintobject(AWCMP_LOSSLESS)); |
| 1175 | (void) dictinsert(d, "AWCMP_MPEG_LAYER_I", |
| 1176 | newintobject(AWCMP_MPEG_LAYER_I)); |
| 1177 | (void) dictinsert(d, "AWCMP_MPEG_LAYER_II", |
| 1178 | newintobject(AWCMP_MPEG_LAYER_II)); |
| 1179 | (void) dictinsert(d, "HEADER_START_CODE", |
| 1180 | newintobject(CL_HEADER_START_CODE)); |
| 1181 | (void) dictinsert(d, "BAD_NO_BUFFERSPACE", |
| 1182 | newintobject(CL_BAD_NO_BUFFERSPACE)); |
| 1183 | (void) dictinsert(d, "BAD_PVBUFFER", newintobject(CL_BAD_PVBUFFER)); |
| 1184 | (void) dictinsert(d, "BAD_BUFFERLENGTH_NEG", |
| 1185 | newintobject(CL_BAD_BUFFERLENGTH_NEG)); |
| 1186 | (void) dictinsert(d, "BAD_BUFFERLENGTH_ODD", |
| 1187 | newintobject(CL_BAD_BUFFERLENGTH_ODD)); |
| 1188 | (void) dictinsert(d, "BAD_PARAM", newintobject(CL_BAD_PARAM)); |
| 1189 | (void) dictinsert(d, "BAD_COMPRESSION_SCHEME", |
| 1190 | newintobject(CL_BAD_COMPRESSION_SCHEME)); |
| 1191 | (void) dictinsert(d, "BAD_COMPRESSOR_HANDLE", |
| 1192 | newintobject(CL_BAD_COMPRESSOR_HANDLE)); |
| 1193 | (void) dictinsert(d, "BAD_COMPRESSOR_HANDLE_POINTER", |
| 1194 | newintobject(CL_BAD_COMPRESSOR_HANDLE_POINTER)); |
| 1195 | (void) dictinsert(d, "BAD_BUFFER_HANDLE", |
| 1196 | newintobject(CL_BAD_BUFFER_HANDLE)); |
| 1197 | (void) dictinsert(d, "BAD_BUFFER_QUERY_SIZE", |
| 1198 | newintobject(CL_BAD_BUFFER_QUERY_SIZE)); |
| 1199 | (void) dictinsert(d, "JPEG_ERROR", newintobject(CL_JPEG_ERROR)); |
| 1200 | (void) dictinsert(d, "BAD_FRAME_SIZE", |
| 1201 | newintobject(CL_BAD_FRAME_SIZE)); |
| 1202 | (void) dictinsert(d, "PARAM_OUT_OF_RANGE", |
| 1203 | newintobject(CL_PARAM_OUT_OF_RANGE)); |
| 1204 | (void) dictinsert(d, "ADDED_ALGORITHM_ERROR", |
| 1205 | newintobject(CL_ADDED_ALGORITHM_ERROR)); |
| 1206 | (void) dictinsert(d, "BAD_ALGORITHM_TYPE", |
| 1207 | newintobject(CL_BAD_ALGORITHM_TYPE)); |
| 1208 | (void) dictinsert(d, "BAD_ALGORITHM_NAME", |
| 1209 | newintobject(CL_BAD_ALGORITHM_NAME)); |
| 1210 | (void) dictinsert(d, "BAD_BUFFERING", newintobject(CL_BAD_BUFFERING)); |
| 1211 | (void) dictinsert(d, "BUFFER_NOT_CREATED", |
| 1212 | newintobject(CL_BUFFER_NOT_CREATED)); |
| 1213 | (void) dictinsert(d, "BAD_BUFFER_EXISTS", |
| 1214 | newintobject(CL_BAD_BUFFER_EXISTS)); |
| 1215 | (void) dictinsert(d, "BAD_INTERNAL_FORMAT", |
| 1216 | newintobject(CL_BAD_INTERNAL_FORMAT)); |
| 1217 | (void) dictinsert(d, "BAD_BUFFER_POINTER", |
| 1218 | newintobject(CL_BAD_BUFFER_POINTER)); |
| 1219 | (void) dictinsert(d, "FRAME_BUFFER_SIZE_ZERO", |
| 1220 | newintobject(CL_FRAME_BUFFER_SIZE_ZERO)); |
| 1221 | (void) dictinsert(d, "BAD_STREAM_HEADER", |
| 1222 | newintobject(CL_BAD_STREAM_HEADER)); |
| 1223 | (void) dictinsert(d, "BAD_LICENSE", newintobject(CL_BAD_LICENSE)); |
| 1224 | (void) dictinsert(d, "AWARE_ERROR", newintobject(CL_AWARE_ERROR)); |
| 1225 | (void) dictinsert(d, "BAD_BUFFER_SIZE_POINTER", |
| 1226 | newintobject(CL_BAD_BUFFER_SIZE_POINTER)); |
| 1227 | (void) dictinsert(d, "BAD_BUFFER_SIZE", |
| 1228 | newintobject(CL_BAD_BUFFER_SIZE)); |
| 1229 | (void) dictinsert(d, "BAD_BUFFER_TYPE", |
| 1230 | newintobject(CL_BAD_BUFFER_TYPE)); |
| 1231 | (void) dictinsert(d, "BAD_HEADER_SIZE", |
| 1232 | newintobject(CL_BAD_HEADER_SIZE)); |
| 1233 | (void) dictinsert(d, "BAD_FUNCTION_POINTER", |
| 1234 | newintobject(CL_BAD_FUNCTION_POINTER)); |
| 1235 | (void) dictinsert(d, "BAD_SCHEME_POINTER", |
| 1236 | newintobject(CL_BAD_SCHEME_POINTER)); |
| 1237 | (void) dictinsert(d, "BAD_STRING_POINTER", |
| 1238 | newintobject(CL_BAD_STRING_POINTER)); |
| 1239 | (void) dictinsert(d, "BAD_MIN_GT_MAX", |
| 1240 | newintobject(CL_BAD_MIN_GT_MAX)); |
| 1241 | (void) dictinsert(d, "BAD_INITIAL_VALUE", |
| 1242 | newintobject(CL_BAD_INITIAL_VALUE)); |
| 1243 | (void) dictinsert(d, "BAD_PARAM_ID_POINTER", |
| 1244 | newintobject(CL_BAD_PARAM_ID_POINTER)); |
| 1245 | (void) dictinsert(d, "BAD_PARAM_TYPE", |
| 1246 | newintobject(CL_BAD_PARAM_TYPE)); |
| 1247 | (void) dictinsert(d, "BAD_TEXT_STRING_PTR", |
| 1248 | newintobject(CL_BAD_TEXT_STRING_PTR)); |
| 1249 | (void) dictinsert(d, "BAD_FUNCTIONALITY", |
| 1250 | newintobject(CL_BAD_FUNCTIONALITY)); |
| 1251 | (void) dictinsert(d, "BAD_NUMBER_OF_BLOCKS", |
| 1252 | newintobject(CL_BAD_NUMBER_OF_BLOCKS)); |
| 1253 | (void) dictinsert(d, "BAD_BLOCK_SIZE", |
| 1254 | newintobject(CL_BAD_BLOCK_SIZE)); |
| 1255 | (void) dictinsert(d, "BAD_POINTER", newintobject(CL_BAD_POINTER)); |
| 1256 | (void) dictinsert(d, "BAD_BOARD", newintobject(CL_BAD_BOARD)); |
| 1257 | (void) dictinsert(d, "MVC2_ERROR", newintobject(CL_MVC2_ERROR)); |
| 1258 | #ifdef IRIX_5_3_LIBRARY |
| 1259 | (void) dictinsert(d, "NEXT_NOT_AVAILABLE", |
| 1260 | newintobject(CL_NEXT_NOT_AVAILABLE)); |
| 1261 | (void) dictinsert(d, "SCHEME_BUSY", newintobject(CL_SCHEME_BUSY)); |
| 1262 | (void) dictinsert(d, "SCHEME_NOT_AVAILABLE", |
| 1263 | newintobject(CL_SCHEME_NOT_AVAILABLE)); |
| 1264 | #endif |
| 1265 | #ifdef CL_LUMA_THRESHOLD |
| 1266 | /* backward compatibility */ |
| 1267 | (void) dictinsert(d, "LUMA_THRESHOLD", |
| 1268 | newintobject(CL_LUMA_THRESHOLD)); |
| 1269 | (void) dictinsert(d, "CHROMA_THRESHOLD", |
| 1270 | newintobject(CL_CHROMA_THRESHOLD)); |
| 1271 | (void) dictinsert(d, "EDGE_THRESHOLD", |
| 1272 | newintobject(CL_EDGE_THRESHOLD)); |
| 1273 | (void) dictinsert(d, "BLENDING", newintobject(CL_BLENDING)); |
| 1274 | (void) dictinsert(d, "QUALITY_FACTOR", |
| 1275 | newintobject(CL_QUALITY_FACTOR)); |
| 1276 | (void) dictinsert(d, "STREAM_HEADERS", |
| 1277 | newintobject(CL_STREAM_HEADERS)); |
| 1278 | (void) dictinsert(d, "QUALITY_LEVEL", newintobject(CL_QUALITY_LEVEL)); |
| 1279 | (void) dictinsert(d, "TILE_THRESHOLD", |
| 1280 | newintobject(CL_TILE_THRESHOLD)); |
| 1281 | (void) dictinsert(d, "SAMPLES_PER_TILE", |
| 1282 | newintobject(CL_SAMPLES_PER_TILE)); |
| 1283 | #endif |
| 1284 | |
| 1285 | if (err_occurred()) |
| 1286 | fatal("can't initialize module cl"); |
Sjoerd Mullender | d53a4f3 | 1992-09-24 10:37:39 +0000 | [diff] [blame] | 1287 | |
| 1288 | (void) clSetErrorHandler(cl_ErrorHandler); |
Sjoerd Mullender | c431549 | 1992-09-23 14:53:00 +0000 | [diff] [blame] | 1289 | } |