1992-09-23 11:53:00 -03:00
|
|
|
/***********************************************************
|
1995-01-04 15:10:35 -04:00
|
|
|
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
|
|
|
|
The Netherlands.
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
1996-10-25 11:44:06 -03:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
1992-09-23 11:53:00 -03:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
1996-10-25 11:44:06 -03:00
|
|
|
both that copyright notice and this permission notice appear in
|
1992-09-23 11:53:00 -03:00
|
|
|
supporting documentation, and that the names of Stichting Mathematisch
|
1996-10-25 11:44:06 -03:00
|
|
|
Centrum or CWI or Corporation for National Research Initiatives or
|
|
|
|
CNRI not be used in advertising or publicity pertaining to
|
|
|
|
distribution of the software without specific, written prior
|
|
|
|
permission.
|
|
|
|
|
|
|
|
While CWI is the initial source for this software, a modified version
|
|
|
|
is made available by the Corporation for National Research Initiatives
|
|
|
|
(CNRI) at the Internet address ftp://ftp.python.org.
|
|
|
|
|
|
|
|
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
|
|
|
|
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
|
|
|
|
CENTRUM OR CNRI 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
|
|
|
|
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
PERFORMANCE OF THIS SOFTWARE.
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/* Cl objects */
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
#define CLDEBUG
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
#include <stdarg.h>
|
1992-09-23 11:53:00 -03:00
|
|
|
#include <cl.h>
|
|
|
|
#include "allobjects.h"
|
|
|
|
#include "modsupport.h" /* For getargs() etc. */
|
|
|
|
#include "ceval.h" /* For call_object() */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
OB_HEAD
|
|
|
|
int ob_isCompressor; /* Compressor or Decompressor */
|
1992-12-14 09:17:29 -04:00
|
|
|
CL_Handle ob_compressorHdl;
|
1993-02-16 07:55:17 -04:00
|
|
|
int *ob_paramtypes;
|
|
|
|
int ob_nparams;
|
1992-09-23 11:53:00 -03:00
|
|
|
} clobject;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
static object *ClError; /* exception cl.error */
|
|
|
|
|
|
|
|
static int error_handler_called = 0;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
/*
|
|
|
|
* We want to use the function prototypes that are available in the C
|
|
|
|
* compiler on the SGI. Because of that, we need to declare the first
|
|
|
|
* argument of the compressor and decompressor methods as "object *",
|
|
|
|
* even though they are really "clobject *". Therefore we cast the
|
|
|
|
* argument to the proper type using this macro.
|
|
|
|
*/
|
|
|
|
#define SELF ((clobject *) self)
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
/********************************************************************
|
|
|
|
Utility routines.
|
|
|
|
********************************************************************/
|
1992-09-24 07:37:39 -03:00
|
|
|
static void
|
1993-02-04 12:43:28 -04:00
|
|
|
cl_ErrorHandler(CL_Handle handle, int code, const char *fmt, ...)
|
1992-09-24 07:37:39 -03:00
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
char errbuf[BUFSIZ]; /* hopefully big enough */
|
1992-09-29 13:43:43 -03:00
|
|
|
char *p;
|
1992-09-24 07:37:39 -03:00
|
|
|
|
1992-09-29 13:43:43 -03:00
|
|
|
if (err_occurred()) /* don't change existing error */
|
|
|
|
return;
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 1;
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vsprintf(errbuf, fmt, ap);
|
|
|
|
va_end(ap);
|
1992-09-29 13:43:43 -03:00
|
|
|
p = &errbuf[strlen(errbuf) - 1]; /* swat the line feed */
|
|
|
|
if (*p == '\n')
|
|
|
|
*p = 0;
|
1992-09-24 07:37:39 -03:00
|
|
|
err_setstr(ClError, errbuf);
|
|
|
|
}
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
/*
|
|
|
|
* This assumes that params are always in the range 0 to some maximum.
|
|
|
|
*/
|
|
|
|
static int
|
1993-02-16 07:55:17 -04:00
|
|
|
param_type_is_float(clobject *self, int param)
|
1992-09-25 07:28:20 -03:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int bufferlength;
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (self->ob_paramtypes == NULL) {
|
|
|
|
error_handler_called = 0;
|
|
|
|
bufferlength = clQueryParams(self->ob_compressorHdl, 0, 0);
|
|
|
|
if (error_handler_called)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
self->ob_paramtypes = NEW(int, bufferlength);
|
|
|
|
if (self->ob_paramtypes == NULL)
|
|
|
|
return -1;
|
|
|
|
self->ob_nparams = bufferlength / 2;
|
|
|
|
|
|
|
|
(void) clQueryParams(self->ob_compressorHdl, self->ob_paramtypes, bufferlength);
|
|
|
|
if (error_handler_called) {
|
|
|
|
DEL(self->ob_paramtypes);
|
|
|
|
self->ob_paramtypes = NULL;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (param < 0 || param >= self->ob_nparams)
|
1992-12-14 09:17:29 -04:00
|
|
|
return -1;
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (self->ob_paramtypes[param*2 + 1] == CL_FLOATING_ENUM_VALUE ||
|
|
|
|
self->ob_paramtypes[param*2 + 1] == CL_FLOATING_RANGE_VALUE)
|
|
|
|
return 1;
|
1992-12-14 09:17:29 -04:00
|
|
|
else
|
1993-02-16 07:55:17 -04:00
|
|
|
return 0;
|
1992-09-25 07:28:20 -03:00
|
|
|
}
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
/********************************************************************
|
|
|
|
Single image compression/decompression.
|
|
|
|
********************************************************************/
|
1992-09-23 11:53:00 -03:00
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_CompressImage(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int compressionScheme, width, height, originalFormat;
|
1992-12-14 09:17:29 -04:00
|
|
|
float compressionRatio;
|
1993-02-04 12:43:28 -04:00
|
|
|
int frameBufferSize, compressedBufferSize;
|
1992-12-14 09:17:29 -04:00
|
|
|
char *frameBuffer;
|
|
|
|
object *compressedBuffer;
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
if (!getargs(args, "(iiiifs#)", &compressionScheme, &width, &height,
|
|
|
|
&originalFormat, &compressionRatio, &frameBuffer,
|
|
|
|
&frameBufferSize))
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
retry:
|
|
|
|
compressedBuffer = newsizedstringobject(NULL, frameBufferSize);
|
|
|
|
if (compressedBuffer == NULL)
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
compressedBufferSize = frameBufferSize;
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1992-12-14 09:17:29 -04:00
|
|
|
if (clCompressImage(compressionScheme, width, height, originalFormat,
|
|
|
|
compressionRatio, (void *) frameBuffer,
|
|
|
|
&compressedBufferSize,
|
|
|
|
(void *) getstringvalue(compressedBuffer))
|
|
|
|
== FAILURE) {
|
|
|
|
DECREF(compressedBuffer);
|
|
|
|
if (!error_handler_called)
|
|
|
|
err_setstr(ClError, "clCompressImage failed");
|
1992-09-24 07:37:39 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
if (compressedBufferSize > frameBufferSize) {
|
|
|
|
frameBufferSize = compressedBufferSize;
|
|
|
|
DECREF(compressedBuffer);
|
|
|
|
goto retry;
|
1992-09-29 13:43:43 -03:00
|
|
|
}
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
if (compressedBufferSize < frameBufferSize)
|
|
|
|
if (resizestring(&compressedBuffer, compressedBufferSize))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return compressedBuffer;
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_DecompressImage(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int compressionScheme, width, height, originalFormat;
|
1992-12-14 09:17:29 -04:00
|
|
|
char *compressedBuffer;
|
1993-02-04 12:43:28 -04:00
|
|
|
int compressedBufferSize, frameBufferSize;
|
1992-12-14 09:17:29 -04:00
|
|
|
object *frameBuffer;
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (!getargs(args, "(iiiis#)", &compressionScheme, &width, &height,
|
|
|
|
&originalFormat, &compressedBuffer,
|
|
|
|
&compressedBufferSize))
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
frameBufferSize = width * height * CL_BytesPerPixel(originalFormat);
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
frameBuffer = newsizedstringobject(NULL, frameBufferSize);
|
|
|
|
if (frameBuffer == NULL)
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1992-12-14 09:17:29 -04:00
|
|
|
if (clDecompressImage(compressionScheme, width, height, originalFormat,
|
|
|
|
compressedBufferSize, compressedBuffer,
|
|
|
|
(void *) getstringvalue(frameBuffer)) == FAILURE) {
|
|
|
|
DECREF(frameBuffer);
|
|
|
|
if (!error_handler_called)
|
|
|
|
err_setstr(ClError, "clDecompressImage failed");
|
1992-09-24 07:37:39 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
return frameBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
Sequential compression/decompression.
|
|
|
|
********************************************************************/
|
|
|
|
#define CheckCompressor(self) if ((self)->ob_compressorHdl == NULL) { \
|
|
|
|
err_setstr(RuntimeError, "(de)compressor not active"); \
|
|
|
|
return NULL; \
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
doClose(clobject *self, object *args, int (*close_func)(CL_Handle))
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1992-09-25 07:28:20 -03:00
|
|
|
CheckCompressor(self);
|
|
|
|
|
1992-09-23 11:53:00 -03:00
|
|
|
if (!getnoarg(args))
|
|
|
|
return NULL;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1992-12-14 09:17:29 -04:00
|
|
|
if ((*close_func)(self->ob_compressorHdl) == FAILURE) {
|
1992-09-24 07:37:39 -03:00
|
|
|
if (!error_handler_called)
|
1992-12-14 09:17:29 -04:00
|
|
|
err_setstr(ClError, "close failed");
|
1992-09-24 07:37:39 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
self->ob_compressorHdl = NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (self->ob_paramtypes)
|
|
|
|
DEL(self->ob_paramtypes);
|
|
|
|
self->ob_paramtypes = NULL;
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
INCREF(None);
|
|
|
|
return None;
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_CloseCompressor(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
return doClose(SELF, args, clCloseCompressor);
|
1992-12-14 09:17:29 -04:00
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_CloseDecompressor(object *self, object *args)
|
1992-12-14 09:17:29 -04:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
return doClose(SELF, args, clCloseDecompressor);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_Compress(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int numberOfFrames;
|
1993-02-16 07:55:17 -04:00
|
|
|
int frameBufferSize, compressedBufferSize, size;
|
1992-12-14 09:17:29 -04:00
|
|
|
char *frameBuffer;
|
|
|
|
object *data;
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
if (!getargs(args, "(is#)", &numberOfFrames, &frameBuffer, &frameBufferSize))
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
size = clGetParam(SELF->ob_compressorHdl, CL_COMPRESSED_BUFFER_SIZE);
|
|
|
|
compressedBufferSize = size;
|
1992-09-24 07:37:39 -03:00
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
data = newsizedstringobject(NULL, size);
|
1992-12-14 09:17:29 -04:00
|
|
|
if (data == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
if (clCompress(SELF->ob_compressorHdl, numberOfFrames,
|
1992-12-14 09:17:29 -04:00
|
|
|
(void *) frameBuffer, &compressedBufferSize,
|
|
|
|
(void *) getstringvalue(data)) == FAILURE) {
|
|
|
|
DECREF(data);
|
|
|
|
if (!error_handler_called)
|
|
|
|
err_setstr(ClError, "compress failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (compressedBufferSize < size)
|
1992-12-14 09:17:29 -04:00
|
|
|
if (resizestring(&data, compressedBufferSize))
|
|
|
|
return NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (compressedBufferSize > size) {
|
1992-12-14 09:17:29 -04:00
|
|
|
/* we didn't get all "compressed" data */
|
|
|
|
DECREF(data);
|
|
|
|
err_setstr(ClError, "compressed data is more than fitted");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return data;
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_Decompress(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1992-12-14 09:17:29 -04:00
|
|
|
object *data;
|
1993-02-04 12:43:28 -04:00
|
|
|
int numberOfFrames;
|
1992-12-14 09:17:29 -04:00
|
|
|
char *compressedData;
|
1993-02-16 07:55:17 -04:00
|
|
|
int compressedDataSize, dataSize;
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
if (!getargs(args, "(is#)", &numberOfFrames, &compressedData,
|
|
|
|
&compressedDataSize))
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
dataSize = clGetParam(SELF->ob_compressorHdl, CL_FRAME_BUFFER_SIZE);
|
1992-09-24 07:37:39 -03:00
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
1992-12-14 09:17:29 -04:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
data = newsizedstringobject(NULL, dataSize);
|
1992-12-14 09:17:29 -04:00
|
|
|
if (data == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
if (clDecompress(SELF->ob_compressorHdl, numberOfFrames,
|
1992-12-14 09:17:29 -04:00
|
|
|
compressedDataSize, (void *) compressedData,
|
|
|
|
(void *) getstringvalue(data)) == FAILURE) {
|
|
|
|
DECREF(data);
|
|
|
|
if (!error_handler_called)
|
|
|
|
err_setstr(ClError, "decompress failed");
|
1992-09-24 07:37:39 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
return data;
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
doParams(clobject *self, object *args, int (*func)(CL_Handle, int *, int),
|
|
|
|
int modified)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
|
|
|
object *list, *v;
|
1993-02-04 12:43:28 -04:00
|
|
|
int *PVbuffer;
|
|
|
|
int length;
|
1992-09-23 11:53:00 -03:00
|
|
|
int i;
|
1993-02-04 12:43:28 -04:00
|
|
|
float number;
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1992-09-25 07:28:20 -03:00
|
|
|
CheckCompressor(self);
|
|
|
|
|
1992-09-23 11:53:00 -03:00
|
|
|
if (!getargs(args, "O", &list))
|
|
|
|
return NULL;
|
|
|
|
if (!is_listobject(list)) {
|
|
|
|
err_badarg();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
length = getlistsize(list);
|
1993-02-04 12:43:28 -04:00
|
|
|
PVbuffer = NEW(int, length);
|
1992-09-23 11:53:00 -03:00
|
|
|
if (PVbuffer == NULL)
|
|
|
|
return err_nomem();
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
v = getlistitem(list, i);
|
1993-02-04 12:43:28 -04:00
|
|
|
if (is_floatobject(v)) {
|
|
|
|
number = getfloatvalue(v);
|
|
|
|
PVbuffer[i] = CL_TypeIsInt(number);
|
1993-02-16 07:55:17 -04:00
|
|
|
} else if (is_intobject(v)) {
|
1992-12-14 09:17:29 -04:00
|
|
|
PVbuffer[i] = getintvalue(v);
|
1993-02-16 07:55:17 -04:00
|
|
|
if ((i & 1) &&
|
|
|
|
param_type_is_float(self, PVbuffer[i-1]) > 0) {
|
|
|
|
number = PVbuffer[i];
|
|
|
|
PVbuffer[i] = CL_TypeIsInt(number);
|
|
|
|
}
|
|
|
|
} else {
|
1992-09-23 11:53:00 -03:00
|
|
|
DEL(PVbuffer);
|
|
|
|
err_badarg();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1992-09-23 11:53:00 -03:00
|
|
|
(*func)(self->ob_compressorHdl, PVbuffer, length);
|
1993-08-03 12:11:36 -03:00
|
|
|
if (error_handler_called) {
|
|
|
|
DEL(PVbuffer);
|
1992-09-24 07:37:39 -03:00
|
|
|
return NULL;
|
1993-08-03 12:11:36 -03:00
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
if (modified) {
|
1992-12-14 09:17:29 -04:00
|
|
|
for (i = 0; i < length; i++) {
|
1993-02-04 12:43:28 -04:00
|
|
|
if ((i & 1) &&
|
1993-02-16 07:55:17 -04:00
|
|
|
param_type_is_float(self, PVbuffer[i-1]) > 0) {
|
1993-02-04 12:43:28 -04:00
|
|
|
number = CL_TypeIsFloat(PVbuffer[i]);
|
|
|
|
v = newfloatobject(number);
|
|
|
|
} else
|
1992-12-14 09:17:29 -04:00
|
|
|
v = newintobject(PVbuffer[i]);
|
|
|
|
setlistitem(list, i, v);
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
DEL(PVbuffer);
|
|
|
|
|
|
|
|
INCREF(None);
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_GetParams(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
return doParams(SELF, args, clGetParams, 1);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_SetParams(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
return doParams(SELF, args, clSetParams, 0);
|
1993-02-04 12:43:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
do_get(clobject *self, object *args, int (*func)(CL_Handle, int))
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
int paramID, value;
|
|
|
|
float fvalue;
|
|
|
|
|
|
|
|
CheckCompressor(self);
|
|
|
|
|
|
|
|
if (!getargs(args, "i", ¶mID))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
|
|
|
value = (*func)(self->ob_compressorHdl, paramID);
|
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (param_type_is_float(self, paramID) > 0) {
|
1993-02-04 12:43:28 -04:00
|
|
|
fvalue = CL_TypeIsFloat(value);
|
|
|
|
return newfloatobject(fvalue);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newintobject(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_GetParam(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
return do_get(SELF, args, clGetParam);
|
1993-02-04 12:43:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_GetDefault(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
return do_get(SELF, args, clGetDefault);
|
1993-02-04 12:43:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_SetParam(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
int paramID, value;
|
|
|
|
float fvalue;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1993-02-04 12:43:28 -04:00
|
|
|
|
|
|
|
if (!getargs(args, "(ii)", ¶mID, &value)) {
|
|
|
|
err_clear();
|
|
|
|
if (!getargs(args, "(if)", ¶mID, &fvalue)) {
|
|
|
|
err_clear();
|
|
|
|
err_setstr(TypeError, "bad argument list (format '(ii)' or '(if)')");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
value = CL_TypeIsInt(fvalue);
|
1993-02-16 07:55:17 -04:00
|
|
|
} else {
|
|
|
|
if (param_type_is_float(SELF, paramID) > 0) {
|
|
|
|
fvalue = value;
|
|
|
|
value = CL_TypeIsInt(fvalue);
|
|
|
|
}
|
1993-02-04 12:43:28 -04:00
|
|
|
}
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
error_handler_called = 0;
|
|
|
|
value = clSetParam(SELF->ob_compressorHdl, paramID, value);
|
1993-02-04 12:43:28 -04:00
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (param_type_is_float(SELF, paramID) > 0)
|
1993-02-04 12:43:28 -04:00
|
|
|
return newfloatobject(CL_TypeIsFloat(value));
|
|
|
|
else
|
|
|
|
return newintobject(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_GetParamID(object *self, object *args)
|
1992-12-14 09:17:29 -04:00
|
|
|
{
|
|
|
|
char *name;
|
1993-02-04 12:43:28 -04:00
|
|
|
int value;
|
1992-12-14 09:17:29 -04:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-12-14 09:17:29 -04:00
|
|
|
|
|
|
|
if (!getargs(args, "s", &name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
value = clGetParamID(SELF->ob_compressorHdl, name);
|
1992-12-14 09:17:29 -04:00
|
|
|
if (value == FAILURE) {
|
|
|
|
if (!error_handler_called)
|
|
|
|
err_setstr(ClError, "getparamid failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newintobject(value);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_QueryParams(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int bufferlength;
|
|
|
|
int *PVbuffer;
|
1992-09-23 11:53:00 -03:00
|
|
|
object *list;
|
|
|
|
int i;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-09-25 07:28:20 -03:00
|
|
|
|
1992-09-23 11:53:00 -03:00
|
|
|
if (!getnoarg(args))
|
|
|
|
return NULL;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
bufferlength = clQueryParams(SELF->ob_compressorHdl, 0, 0);
|
1992-09-24 07:37:39 -03:00
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
1992-09-23 11:53:00 -03:00
|
|
|
|
1993-02-04 12:43:28 -04:00
|
|
|
PVbuffer = NEW(int, bufferlength);
|
1992-09-23 11:53:00 -03:00
|
|
|
if (PVbuffer == NULL)
|
|
|
|
return err_nomem();
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
bufferlength = clQueryParams(SELF->ob_compressorHdl, PVbuffer,
|
1992-09-23 11:53:00 -03:00
|
|
|
bufferlength);
|
1992-09-24 07:37:39 -03:00
|
|
|
if (error_handler_called) {
|
|
|
|
DEL(PVbuffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
list = newlistobject(bufferlength);
|
|
|
|
if (list == NULL) {
|
|
|
|
DEL(PVbuffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
for (i = 0; i < bufferlength; i++) {
|
|
|
|
if (i & 1)
|
|
|
|
setlistitem(list, i, newintobject(PVbuffer[i]));
|
1992-12-14 09:17:29 -04:00
|
|
|
else if (PVbuffer[i] == 0) {
|
|
|
|
INCREF(None);
|
|
|
|
setlistitem(list, i, None);
|
|
|
|
} else
|
1992-09-24 07:37:39 -03:00
|
|
|
setlistitem(list, i, newstringobject((char *) PVbuffer[i]));
|
|
|
|
}
|
1992-09-23 11:53:00 -03:00
|
|
|
|
|
|
|
DEL(PVbuffer);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_GetMinMax(object *self, object *args)
|
1992-12-14 09:17:29 -04:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int param, min, max;
|
|
|
|
float fmin, fmax;
|
1992-12-14 09:17:29 -04:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-12-14 09:17:29 -04:00
|
|
|
|
|
|
|
if (!getargs(args, "i", ¶m))
|
|
|
|
return NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
clGetMinMax(SELF->ob_compressorHdl, param, &min, &max);
|
1992-12-14 09:17:29 -04:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
if (param_type_is_float(SELF, param) > 0) {
|
1993-02-04 12:43:28 -04:00
|
|
|
fmin = CL_TypeIsFloat(min);
|
|
|
|
fmax = CL_TypeIsFloat(max);
|
1992-12-14 09:17:29 -04:00
|
|
|
return mkvalue("(ff)", fmin, fmax);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mkvalue("(ii)", min, max);
|
|
|
|
}
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
static object *
|
|
|
|
clm_GetName(object *self, object *args)
|
1992-12-14 09:17:29 -04:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int param;
|
1992-12-14 09:17:29 -04:00
|
|
|
char *name;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-12-14 09:17:29 -04:00
|
|
|
|
|
|
|
if (!getargs(args, "i", ¶m))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
1993-02-16 07:55:17 -04:00
|
|
|
name = clGetName(SELF->ob_compressorHdl, param);
|
1992-12-14 09:17:29 -04:00
|
|
|
if (name == NULL || error_handler_called) {
|
|
|
|
if (!error_handler_called)
|
|
|
|
err_setstr(ClError, "getname failed");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newstringobject(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
clm_QuerySchemeFromHandle(object *self, object *args)
|
|
|
|
{
|
|
|
|
CheckCompressor(SELF);
|
|
|
|
|
|
|
|
if (!getnoarg(args))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return newintobject(clQuerySchemeFromHandle(SELF->ob_compressorHdl));
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
|
|
|
clm_ReadHeader(object *self, object *args)
|
1992-12-14 09:17:29 -04:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
char *header;
|
|
|
|
int headerSize;
|
1992-12-14 09:17:29 -04:00
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
CheckCompressor(SELF);
|
1992-12-14 09:17:29 -04:00
|
|
|
|
1993-02-04 12:43:28 -04:00
|
|
|
if (!getargs(args, "s#", &header, &headerSize))
|
1992-12-14 09:17:29 -04:00
|
|
|
return NULL;
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
return newintobject(clReadHeader(SELF->ob_compressorHdl,
|
1993-02-04 12:43:28 -04:00
|
|
|
headerSize, header));
|
1992-12-14 09:17:29 -04:00
|
|
|
}
|
|
|
|
|
1992-09-23 11:53:00 -03:00
|
|
|
static struct methodlist compressor_methods[] = {
|
1992-12-14 09:17:29 -04:00
|
|
|
{"close", clm_CloseCompressor}, /* alias */
|
1992-09-29 13:43:43 -03:00
|
|
|
{"CloseCompressor", clm_CloseCompressor},
|
|
|
|
{"Compress", clm_Compress},
|
|
|
|
{"GetDefault", clm_GetDefault},
|
|
|
|
{"GetMinMax", clm_GetMinMax},
|
|
|
|
{"GetName", clm_GetName},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"GetParam", clm_GetParam},
|
1992-12-14 09:17:29 -04:00
|
|
|
{"GetParamID", clm_GetParamID},
|
1992-09-29 13:43:43 -03:00
|
|
|
{"GetParams", clm_GetParams},
|
|
|
|
{"QueryParams", clm_QueryParams},
|
1993-02-16 07:55:17 -04:00
|
|
|
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"SetParam", clm_SetParam},
|
1992-09-29 13:43:43 -03:00
|
|
|
{"SetParams", clm_SetParams},
|
1992-09-23 11:53:00 -03:00
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct methodlist decompressor_methods[] = {
|
1992-12-14 09:17:29 -04:00
|
|
|
{"close", clm_CloseDecompressor}, /* alias */
|
1992-09-29 13:43:43 -03:00
|
|
|
{"CloseDecompressor", clm_CloseDecompressor},
|
|
|
|
{"Decompress", clm_Decompress},
|
|
|
|
{"GetDefault", clm_GetDefault},
|
|
|
|
{"GetMinMax", clm_GetMinMax},
|
|
|
|
{"GetName", clm_GetName},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"GetParam", clm_GetParam},
|
1992-12-14 09:17:29 -04:00
|
|
|
{"GetParamID", clm_GetParamID},
|
1992-09-29 13:43:43 -03:00
|
|
|
{"GetParams", clm_GetParams},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"ReadHeader", clm_ReadHeader},
|
1992-09-29 13:43:43 -03:00
|
|
|
{"QueryParams", clm_QueryParams},
|
1993-02-16 07:55:17 -04:00
|
|
|
{"QuerySchemeFromHandle",clm_QuerySchemeFromHandle},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"SetParam", clm_SetParam},
|
1992-09-29 13:43:43 -03:00
|
|
|
{"SetParams", clm_SetParams},
|
1992-09-23 11:53:00 -03:00
|
|
|
{NULL, NULL} /* sentinel */
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_dealloc(object *self)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
if (SELF->ob_compressorHdl) {
|
|
|
|
if (SELF->ob_isCompressor)
|
|
|
|
clCloseCompressor(SELF->ob_compressorHdl);
|
1992-09-23 11:53:00 -03:00
|
|
|
else
|
1993-02-16 07:55:17 -04:00
|
|
|
clCloseDecompressor(SELF->ob_compressorHdl);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
DEL(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_getattr(object *self, char *name)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-16 07:55:17 -04:00
|
|
|
if (SELF->ob_isCompressor)
|
|
|
|
return findmethod(compressor_methods, self, name);
|
1992-09-23 11:53:00 -03:00
|
|
|
else
|
1993-02-16 07:55:17 -04:00
|
|
|
return findmethod(decompressor_methods, self, name);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static typeobject Cltype = {
|
|
|
|
OB_HEAD_INIT(&Typetype)
|
|
|
|
0, /*ob_size*/
|
|
|
|
"cl", /*tp_name*/
|
|
|
|
sizeof(clobject), /*tp_size*/
|
|
|
|
0, /*tp_itemsize*/
|
|
|
|
/* methods */
|
1994-08-01 08:34:53 -03:00
|
|
|
(destructor)cl_dealloc, /*tp_dealloc*/
|
1992-09-23 11:53:00 -03:00
|
|
|
0, /*tp_print*/
|
1994-08-01 08:34:53 -03:00
|
|
|
(getattrfunc)cl_getattr, /*tp_getattr*/
|
1992-09-23 11:53:00 -03:00
|
|
|
0, /*tp_setattr*/
|
|
|
|
0, /*tp_compare*/
|
|
|
|
0, /*tp_repr*/
|
|
|
|
0, /*tp_as_number*/
|
|
|
|
0, /*tp_as_sequence*/
|
|
|
|
0, /*tp_as_mapping*/
|
|
|
|
};
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
doOpen(object *self, object *args, int (*open_func)(int, CL_Handle *),
|
|
|
|
int iscompressor)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1993-02-04 12:43:28 -04:00
|
|
|
int scheme;
|
1992-09-23 11:53:00 -03:00
|
|
|
clobject *new;
|
|
|
|
|
1992-12-14 09:17:29 -04:00
|
|
|
if (!getargs(args, "i", &scheme))
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
new = NEWOBJ(clobject, &Cltype);
|
1992-12-14 09:17:29 -04:00
|
|
|
if (new == NULL)
|
1992-09-23 11:53:00 -03:00
|
|
|
return NULL;
|
|
|
|
|
1992-09-24 07:37:39 -03:00
|
|
|
new->ob_compressorHdl = NULL;
|
1992-12-14 09:17:29 -04:00
|
|
|
new->ob_isCompressor = iscompressor;
|
1993-02-16 07:55:17 -04:00
|
|
|
new->ob_paramtypes = NULL;
|
1992-09-24 07:37:39 -03:00
|
|
|
|
|
|
|
error_handler_called = 0;
|
1992-12-14 09:17:29 -04:00
|
|
|
if ((*open_func)(scheme, &new->ob_compressorHdl) == FAILURE) {
|
1992-09-24 07:37:39 -03:00
|
|
|
DECREF(new);
|
|
|
|
if (!error_handler_called)
|
1992-12-14 09:17:29 -04:00
|
|
|
err_setstr(ClError, "Open(De)Compressor failed");
|
1992-09-24 07:37:39 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
1994-08-01 08:34:53 -03:00
|
|
|
return (object *)new;
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_OpenCompressor(object *self, object *args)
|
1992-09-23 11:53:00 -03:00
|
|
|
{
|
1992-12-14 09:17:29 -04:00
|
|
|
return doOpen(self, args, clOpenCompressor, 1);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_OpenDecompressor(object *self, object *args)
|
1992-09-29 13:43:43 -03:00
|
|
|
{
|
1992-12-14 09:17:29 -04:00
|
|
|
return doOpen(self, args, clOpenDecompressor, 0);
|
1992-09-29 13:43:43 -03:00
|
|
|
}
|
|
|
|
|
1993-02-04 12:43:28 -04:00
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_QueryScheme(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
char *header;
|
|
|
|
int headerlen;
|
|
|
|
int scheme;
|
|
|
|
|
|
|
|
if (!getargs(args, "s#", &header, &headerlen))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
scheme = clQueryScheme(header);
|
|
|
|
if (scheme < 0) {
|
|
|
|
err_setstr(ClError, "unknown compression scheme");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newintobject(scheme);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_QueryMaxHeaderSize(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
int scheme;
|
|
|
|
|
|
|
|
if (!getargs(args, "i", &scheme))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return newintobject(clQueryMaxHeaderSize(scheme));
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_QueryAlgorithms(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
int algorithmMediaType;
|
|
|
|
int bufferlength;
|
|
|
|
int *PVbuffer;
|
|
|
|
object *list;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!getargs(args, "i", &algorithmMediaType))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
|
|
|
bufferlength = clQueryAlgorithms(algorithmMediaType, 0, 0);
|
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
PVbuffer = NEW(int, bufferlength);
|
|
|
|
if (PVbuffer == NULL)
|
|
|
|
return err_nomem();
|
|
|
|
|
|
|
|
bufferlength = clQueryAlgorithms(algorithmMediaType, PVbuffer,
|
|
|
|
bufferlength);
|
|
|
|
if (error_handler_called) {
|
|
|
|
DEL(PVbuffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
list = newlistobject(bufferlength);
|
|
|
|
if (list == NULL) {
|
|
|
|
DEL(PVbuffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < bufferlength; i++) {
|
|
|
|
if (i & 1)
|
|
|
|
setlistitem(list, i, newintobject(PVbuffer[i]));
|
|
|
|
else if (PVbuffer[i] == 0) {
|
|
|
|
INCREF(None);
|
|
|
|
setlistitem(list, i, None);
|
|
|
|
} else
|
|
|
|
setlistitem(list, i, newstringobject((char *) PVbuffer[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
DEL(PVbuffer);
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_QuerySchemeFromName(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
int algorithmMediaType;
|
|
|
|
char *name;
|
|
|
|
int scheme;
|
|
|
|
|
|
|
|
if (!getargs(args, "(is)", &algorithmMediaType, &name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
|
|
|
scheme = clQuerySchemeFromName(algorithmMediaType, name);
|
|
|
|
if (error_handler_called) {
|
|
|
|
err_setstr(ClError, "unknown compression scheme");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newintobject(scheme);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
1993-02-16 07:55:17 -04:00
|
|
|
cl_GetAlgorithmName(object *self, object *args)
|
1993-02-04 12:43:28 -04:00
|
|
|
{
|
|
|
|
int scheme;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
if (!getargs(args, "i", &scheme))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
name = clGetAlgorithmName(scheme);
|
|
|
|
if (name == 0) {
|
|
|
|
err_setstr(ClError, "unknown compression scheme");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newstringobject(name);
|
|
|
|
}
|
|
|
|
|
1993-02-17 05:11:14 -04:00
|
|
|
static object *
|
|
|
|
do_set(object *self, object *args, int (*func)(int, int, int))
|
|
|
|
{
|
|
|
|
int scheme, paramID, value;
|
|
|
|
float fvalue;
|
|
|
|
int is_float = 0;
|
|
|
|
|
|
|
|
if (!getargs(args, "(iii)", &scheme, ¶mID, &value)) {
|
|
|
|
err_clear();
|
|
|
|
if (!getargs(args, "(iif)", &scheme, ¶mID, &fvalue)) {
|
|
|
|
err_clear();
|
|
|
|
err_setstr(TypeError, "bad argument list (format '(iii)' or '(iif)')");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
value = CL_TypeIsInt(fvalue);
|
|
|
|
is_float = 1;
|
|
|
|
} else {
|
|
|
|
/* check some parameters which we know to be floats */
|
|
|
|
switch (scheme) {
|
|
|
|
case CL_COMPRESSION_RATIO:
|
|
|
|
case CL_SPEED:
|
|
|
|
fvalue = value;
|
|
|
|
value = CL_TypeIsInt(fvalue);
|
|
|
|
is_float = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
error_handler_called = 0;
|
|
|
|
value = (*func)(scheme, paramID, value);
|
|
|
|
if (error_handler_called)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (is_float)
|
|
|
|
return newfloatobject(CL_TypeIsFloat(value));
|
|
|
|
else
|
|
|
|
return newintobject(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
|
|
|
cl_SetDefault(object *self, object *args)
|
|
|
|
{
|
|
|
|
return do_set(self, args, clSetDefault);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
|
|
|
cl_SetMin(object *self, object *args)
|
|
|
|
{
|
|
|
|
return do_set(self, args, clSetMin);
|
|
|
|
}
|
|
|
|
|
|
|
|
static object *
|
|
|
|
cl_SetMax(object *self, object *args)
|
|
|
|
{
|
|
|
|
return do_set(self, args, clSetMax);
|
|
|
|
}
|
|
|
|
|
1995-05-17 08:16:52 -03:00
|
|
|
#define func(name, type) \
|
|
|
|
static object *cl_##name(object *self, object *args) \
|
|
|
|
{ \
|
|
|
|
int x; \
|
|
|
|
if (!getargs(args, "i", &x)) return NULL; \
|
|
|
|
return new##type##object(CL_##name(x)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define func2(name, type) \
|
|
|
|
static object *cl_##name(object *self, object *args) \
|
|
|
|
{ \
|
|
|
|
int a1, a2; \
|
|
|
|
if (!getargs(args, "(ii)", &a1, &a2)) return NULL; \
|
|
|
|
return new##type##object(CL_##name(a1, a2)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
func(BytesPerSample,int)
|
|
|
|
func(BytesPerPixel,int)
|
|
|
|
func(AudioFormatName,string)
|
|
|
|
func(VideoFormatName,string)
|
|
|
|
func(AlgorithmNumber,int)
|
|
|
|
func(AlgorithmType,int)
|
|
|
|
func2(Algorithm,int)
|
|
|
|
func(ParamNumber,int)
|
|
|
|
func(ParamType,int)
|
|
|
|
func2(ParamID,int)
|
|
|
|
|
1993-02-16 07:55:17 -04:00
|
|
|
#ifdef CLDEBUG
|
|
|
|
static object *
|
|
|
|
cvt_type(object *self, object *args)
|
|
|
|
{
|
|
|
|
int number;
|
|
|
|
float fnumber;
|
|
|
|
|
|
|
|
if (getargs(args, "i", &number))
|
|
|
|
return newfloatobject(CL_TypeIsFloat(number));
|
|
|
|
else {
|
|
|
|
err_clear();
|
|
|
|
if (getargs(args, "f", &fnumber))
|
|
|
|
return newintobject(CL_TypeIsInt(fnumber));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1992-09-23 11:53:00 -03:00
|
|
|
static struct methodlist cl_methods[] = {
|
1992-12-14 09:17:29 -04:00
|
|
|
{"CompressImage", cl_CompressImage},
|
|
|
|
{"DecompressImage", cl_DecompressImage},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"GetAlgorithmName", cl_GetAlgorithmName},
|
1992-09-23 11:53:00 -03:00
|
|
|
{"OpenCompressor", cl_OpenCompressor},
|
|
|
|
{"OpenDecompressor", cl_OpenDecompressor},
|
1993-02-04 12:43:28 -04:00
|
|
|
{"QueryAlgorithms", cl_QueryAlgorithms},
|
|
|
|
{"QueryMaxHeaderSize", cl_QueryMaxHeaderSize},
|
|
|
|
{"QueryScheme", cl_QueryScheme},
|
|
|
|
{"QuerySchemeFromName", cl_QuerySchemeFromName},
|
1993-02-17 05:11:14 -04:00
|
|
|
{"SetDefault", cl_SetDefault},
|
|
|
|
{"SetMax", cl_SetMax},
|
|
|
|
{"SetMin", cl_SetMin},
|
1995-05-17 08:16:52 -03:00
|
|
|
{"BytesPerSample", cl_BytesPerSample},
|
|
|
|
{"BytesPerPixel", cl_BytesPerPixel},
|
|
|
|
{"AudioFormatName", cl_AudioFormatName},
|
|
|
|
{"VideoFormatName", cl_VideoFormatName},
|
|
|
|
{"AlgorithmNumber", cl_AlgorithmNumber},
|
|
|
|
{"AlgorithmType", cl_AlgorithmType},
|
|
|
|
{"Algorithm", cl_Algorithm},
|
|
|
|
{"ParamNumber", cl_ParamNumber},
|
|
|
|
{"ParamType", cl_ParamType},
|
|
|
|
{"ParamID", cl_ParamID},
|
1993-02-16 07:55:17 -04:00
|
|
|
#ifdef CLDEBUG
|
|
|
|
{"cvt_type", cvt_type},
|
|
|
|
#endif
|
1992-09-23 11:53:00 -03:00
|
|
|
{NULL, NULL} /* Sentinel */
|
|
|
|
};
|
|
|
|
|
1995-05-17 08:16:52 -03:00
|
|
|
#ifdef CL_JPEG_SOFTWARE
|
|
|
|
#define IRIX_5_3_LIBRARY
|
|
|
|
#endif
|
|
|
|
|
1992-09-23 11:53:00 -03:00
|
|
|
void
|
|
|
|
initcl()
|
|
|
|
{
|
1992-09-24 07:37:39 -03:00
|
|
|
object *m, *d;
|
|
|
|
|
|
|
|
m = initmodule("cl", cl_methods);
|
|
|
|
d = getmoduledict(m);
|
|
|
|
|
|
|
|
ClError = newstringobject("cl.error");
|
1995-05-17 08:16:52 -03:00
|
|
|
(void) dictinsert(d, "error", ClError);
|
|
|
|
|
|
|
|
(void) dictinsert(d, "MAX_NUMBER_OF_ORIGINAL_FORMATS",
|
|
|
|
newintobject(CL_MAX_NUMBER_OF_ORIGINAL_FORMATS));
|
|
|
|
(void) dictinsert(d, "MONO", newintobject(CL_MONO));
|
|
|
|
(void) dictinsert(d, "STEREO_INTERLEAVED",
|
|
|
|
newintobject(CL_STEREO_INTERLEAVED));
|
|
|
|
(void) dictinsert(d, "RGB", newintobject(CL_RGB));
|
|
|
|
(void) dictinsert(d, "RGBX", newintobject(CL_RGBX));
|
|
|
|
(void) dictinsert(d, "RGBA", newintobject(CL_RGBA));
|
|
|
|
(void) dictinsert(d, "RGB332", newintobject(CL_RGB332));
|
|
|
|
(void) dictinsert(d, "GRAYSCALE", newintobject(CL_GRAYSCALE));
|
|
|
|
(void) dictinsert(d, "Y", newintobject(CL_Y));
|
|
|
|
(void) dictinsert(d, "YUV", newintobject(CL_YUV));
|
|
|
|
(void) dictinsert(d, "YCbCr", newintobject(CL_YCbCr));
|
|
|
|
(void) dictinsert(d, "YUV422", newintobject(CL_YUV422));
|
|
|
|
(void) dictinsert(d, "YCbCr422", newintobject(CL_YCbCr422));
|
|
|
|
(void) dictinsert(d, "YUV422HC", newintobject(CL_YUV422HC));
|
|
|
|
(void) dictinsert(d, "YCbCr422HC", newintobject(CL_YCbCr422HC));
|
|
|
|
(void) dictinsert(d, "YUV422DC", newintobject(CL_YUV422DC));
|
|
|
|
(void) dictinsert(d, "YCbCr422DC", newintobject(CL_YCbCr422DC));
|
|
|
|
(void) dictinsert(d, "RGB8", newintobject(CL_RGB8));
|
|
|
|
(void) dictinsert(d, "BEST_FIT", newintobject(CL_BEST_FIT));
|
|
|
|
(void) dictinsert(d, "MAX_NUMBER_OF_AUDIO_ALGORITHMS",
|
|
|
|
newintobject(CL_MAX_NUMBER_OF_AUDIO_ALGORITHMS));
|
|
|
|
(void) dictinsert(d, "MAX_NUMBER_OF_VIDEO_ALGORITHMS",
|
|
|
|
newintobject(CL_MAX_NUMBER_OF_VIDEO_ALGORITHMS));
|
|
|
|
(void) dictinsert(d, "AUDIO", newintobject(CL_AUDIO));
|
|
|
|
(void) dictinsert(d, "VIDEO", newintobject(CL_VIDEO));
|
|
|
|
(void) dictinsert(d, "UNKNOWN_SCHEME",
|
|
|
|
newintobject(CL_UNKNOWN_SCHEME));
|
|
|
|
(void) dictinsert(d, "UNCOMPRESSED_AUDIO",
|
|
|
|
newintobject(CL_UNCOMPRESSED_AUDIO));
|
|
|
|
(void) dictinsert(d, "G711_ULAW", newintobject(CL_G711_ULAW));
|
|
|
|
(void) dictinsert(d, "ULAW", newintobject(CL_ULAW));
|
|
|
|
(void) dictinsert(d, "G711_ALAW", newintobject(CL_G711_ALAW));
|
|
|
|
(void) dictinsert(d, "ALAW", newintobject(CL_ALAW));
|
|
|
|
(void) dictinsert(d, "AWARE_MPEG_AUDIO",
|
|
|
|
newintobject(CL_AWARE_MPEG_AUDIO));
|
|
|
|
(void) dictinsert(d, "AWARE_MULTIRATE",
|
|
|
|
newintobject(CL_AWARE_MULTIRATE));
|
|
|
|
(void) dictinsert(d, "UNCOMPRESSED", newintobject(CL_UNCOMPRESSED));
|
|
|
|
(void) dictinsert(d, "UNCOMPRESSED_VIDEO",
|
|
|
|
newintobject(CL_UNCOMPRESSED_VIDEO));
|
|
|
|
(void) dictinsert(d, "RLE", newintobject(CL_RLE));
|
|
|
|
(void) dictinsert(d, "JPEG", newintobject(CL_JPEG));
|
|
|
|
#ifdef IRIX_5_3_LIBRARY
|
|
|
|
(void) dictinsert(d, "JPEG_SOFTWARE", newintobject(CL_JPEG_SOFTWARE));
|
|
|
|
#endif
|
|
|
|
(void) dictinsert(d, "MPEG_VIDEO", newintobject(CL_MPEG_VIDEO));
|
|
|
|
(void) dictinsert(d, "MVC1", newintobject(CL_MVC1));
|
|
|
|
(void) dictinsert(d, "RTR", newintobject(CL_RTR));
|
|
|
|
(void) dictinsert(d, "RTR1", newintobject(CL_RTR1));
|
|
|
|
(void) dictinsert(d, "HDCC", newintobject(CL_HDCC));
|
|
|
|
(void) dictinsert(d, "MVC2", newintobject(CL_MVC2));
|
|
|
|
(void) dictinsert(d, "RLE24", newintobject(CL_RLE24));
|
|
|
|
(void) dictinsert(d, "MAX_NUMBER_OF_PARAMS",
|
|
|
|
newintobject(CL_MAX_NUMBER_OF_PARAMS));
|
|
|
|
(void) dictinsert(d, "IMAGE_WIDTH", newintobject(CL_IMAGE_WIDTH));
|
|
|
|
(void) dictinsert(d, "IMAGE_HEIGHT", newintobject(CL_IMAGE_HEIGHT));
|
|
|
|
(void) dictinsert(d, "ORIGINAL_FORMAT",
|
|
|
|
newintobject(CL_ORIGINAL_FORMAT));
|
|
|
|
(void) dictinsert(d, "INTERNAL_FORMAT",
|
|
|
|
newintobject(CL_INTERNAL_FORMAT));
|
|
|
|
(void) dictinsert(d, "COMPONENTS", newintobject(CL_COMPONENTS));
|
|
|
|
(void) dictinsert(d, "BITS_PER_COMPONENT",
|
|
|
|
newintobject(CL_BITS_PER_COMPONENT));
|
|
|
|
(void) dictinsert(d, "FRAME_RATE", newintobject(CL_FRAME_RATE));
|
|
|
|
(void) dictinsert(d, "COMPRESSION_RATIO",
|
|
|
|
newintobject(CL_COMPRESSION_RATIO));
|
|
|
|
(void) dictinsert(d, "EXACT_COMPRESSION_RATIO",
|
|
|
|
newintobject(CL_EXACT_COMPRESSION_RATIO));
|
|
|
|
(void) dictinsert(d, "FRAME_BUFFER_SIZE",
|
|
|
|
newintobject(CL_FRAME_BUFFER_SIZE));
|
|
|
|
(void) dictinsert(d, "COMPRESSED_BUFFER_SIZE",
|
|
|
|
newintobject(CL_COMPRESSED_BUFFER_SIZE));
|
|
|
|
(void) dictinsert(d, "BLOCK_SIZE", newintobject(CL_BLOCK_SIZE));
|
|
|
|
(void) dictinsert(d, "PREROLL", newintobject(CL_PREROLL));
|
|
|
|
(void) dictinsert(d, "FRAME_TYPE", newintobject(CL_FRAME_TYPE));
|
|
|
|
(void) dictinsert(d, "ALGORITHM_ID", newintobject(CL_ALGORITHM_ID));
|
|
|
|
(void) dictinsert(d, "ALGORITHM_VERSION",
|
|
|
|
newintobject(CL_ALGORITHM_VERSION));
|
|
|
|
(void) dictinsert(d, "ORIENTATION", newintobject(CL_ORIENTATION));
|
|
|
|
(void) dictinsert(d, "NUMBER_OF_FRAMES",
|
|
|
|
newintobject(CL_NUMBER_OF_FRAMES));
|
|
|
|
(void) dictinsert(d, "SPEED", newintobject(CL_SPEED));
|
|
|
|
(void) dictinsert(d, "LAST_FRAME_INDEX",
|
|
|
|
newintobject(CL_LAST_FRAME_INDEX));
|
|
|
|
#ifdef IRIX_5_3_LIBRARY
|
|
|
|
(void) dictinsert(d, "ENABLE_IMAGEINFO",
|
|
|
|
newintobject(CL_ENABLE_IMAGEINFO));
|
|
|
|
(void) dictinsert(d, "INTERNAL_IMAGE_WIDTH",
|
|
|
|
newintobject(CL_INTERNAL_IMAGE_WIDTH));
|
|
|
|
(void) dictinsert(d, "INTERNAL_IMAGE_HEIGHT",
|
|
|
|
newintobject(CL_INTERNAL_IMAGE_HEIGHT));
|
|
|
|
#endif
|
|
|
|
(void) dictinsert(d, "NUMBER_OF_PARAMS",
|
|
|
|
newintobject(CL_NUMBER_OF_PARAMS));
|
|
|
|
#ifdef IRIX_5_3_LIBRARY
|
|
|
|
(void) dictinsert(d, "MVC2_LUMA_THRESHOLD",
|
|
|
|
newintobject(CL_MVC2_LUMA_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "MVC2_CHROMA_THRESHOLD",
|
|
|
|
newintobject(CL_MVC2_CHROMA_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "MVC2_EDGE_THRESHOLD",
|
|
|
|
newintobject(CL_MVC2_EDGE_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "MVC2_BLENDING", newintobject(CL_MVC2_BLENDING));
|
|
|
|
(void) dictinsert(d, "MVC2_BLENDING_OFF",
|
|
|
|
newintobject(CL_MVC2_BLENDING_OFF));
|
|
|
|
(void) dictinsert(d, "MVC2_BLENDING_ON",
|
|
|
|
newintobject(CL_MVC2_BLENDING_ON));
|
|
|
|
(void) dictinsert(d, "JPEG_QUALITY_FACTOR",
|
|
|
|
newintobject(CL_JPEG_QUALITY_FACTOR));
|
|
|
|
(void) dictinsert(d, "JPEG_STREAM_HEADERS",
|
|
|
|
newintobject(CL_JPEG_STREAM_HEADERS));
|
|
|
|
(void) dictinsert(d, "JPEG_QUANTIZATION_TABLES",
|
|
|
|
newintobject(CL_JPEG_QUANTIZATION_TABLES));
|
|
|
|
(void) dictinsert(d, "JPEG_NUM_PARAMS",
|
|
|
|
newintobject(CL_JPEG_NUM_PARAMS));
|
|
|
|
(void) dictinsert(d, "RTR_QUALITY_LEVEL",
|
|
|
|
newintobject(CL_RTR_QUALITY_LEVEL));
|
|
|
|
(void) dictinsert(d, "HDCC_TILE_THRESHOLD",
|
|
|
|
newintobject(CL_HDCC_TILE_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "HDCC_SAMPLES_PER_TILE",
|
|
|
|
newintobject(CL_HDCC_SAMPLES_PER_TILE));
|
|
|
|
#endif
|
|
|
|
(void) dictinsert(d, "END_OF_SEQUENCE",
|
|
|
|
newintobject(CL_END_OF_SEQUENCE));
|
|
|
|
(void) dictinsert(d, "CHANNEL_POLICY",
|
|
|
|
newintobject(CL_CHANNEL_POLICY));
|
|
|
|
(void) dictinsert(d, "NOISE_MARGIN", newintobject(CL_NOISE_MARGIN));
|
|
|
|
(void) dictinsert(d, "BITRATE_POLICY",
|
|
|
|
newintobject(CL_BITRATE_POLICY));
|
|
|
|
(void) dictinsert(d, "BITRATE_TARGET",
|
|
|
|
newintobject(CL_BITRATE_TARGET));
|
|
|
|
(void) dictinsert(d, "LAYER", newintobject(CL_LAYER));
|
|
|
|
(void) dictinsert(d, "ENUM_VALUE", newintobject(CL_ENUM_VALUE));
|
|
|
|
(void) dictinsert(d, "RANGE_VALUE", newintobject(CL_RANGE_VALUE));
|
|
|
|
(void) dictinsert(d, "FLOATING_ENUM_VALUE",
|
|
|
|
newintobject(CL_FLOATING_ENUM_VALUE));
|
|
|
|
(void) dictinsert(d, "FLOATING_RANGE_VALUE",
|
|
|
|
newintobject(CL_FLOATING_RANGE_VALUE));
|
|
|
|
(void) dictinsert(d, "DECOMPRESSOR", newintobject(CL_DECOMPRESSOR));
|
|
|
|
(void) dictinsert(d, "COMPRESSOR", newintobject(CL_COMPRESSOR));
|
|
|
|
(void) dictinsert(d, "CODEC", newintobject(CL_CODEC));
|
|
|
|
(void) dictinsert(d, "NONE", newintobject(CL_NONE));
|
|
|
|
#ifdef IRIX_5_3_LIBRARY
|
|
|
|
(void) dictinsert(d, "BUF_FRAME", newintobject(CL_BUF_FRAME));
|
|
|
|
(void) dictinsert(d, "BUF_DATA", newintobject(CL_BUF_DATA));
|
|
|
|
#endif
|
|
|
|
#ifdef CL_FRAME
|
|
|
|
(void) dictinsert(d, "FRAME", newintobject(CL_FRAME));
|
|
|
|
(void) dictinsert(d, "DATA", newintobject(CL_DATA));
|
|
|
|
#endif
|
|
|
|
(void) dictinsert(d, "NONE", newintobject(CL_NONE));
|
|
|
|
(void) dictinsert(d, "KEYFRAME", newintobject(CL_KEYFRAME));
|
|
|
|
(void) dictinsert(d, "INTRA", newintobject(CL_INTRA));
|
|
|
|
(void) dictinsert(d, "PREDICTED", newintobject(CL_PREDICTED));
|
|
|
|
(void) dictinsert(d, "BIDIRECTIONAL", newintobject(CL_BIDIRECTIONAL));
|
|
|
|
(void) dictinsert(d, "TOP_DOWN", newintobject(CL_TOP_DOWN));
|
|
|
|
(void) dictinsert(d, "BOTTOM_UP", newintobject(CL_BOTTOM_UP));
|
|
|
|
#ifdef IRIX_5_3_LIBRARY
|
|
|
|
(void) dictinsert(d, "CONTINUOUS_BLOCK",
|
|
|
|
newintobject(CL_CONTINUOUS_BLOCK));
|
|
|
|
(void) dictinsert(d, "CONTINUOUS_NONBLOCK",
|
|
|
|
newintobject(CL_CONTINUOUS_NONBLOCK));
|
|
|
|
(void) dictinsert(d, "EXTERNAL_DEVICE",
|
|
|
|
newintobject((long)CL_EXTERNAL_DEVICE));
|
|
|
|
#endif
|
|
|
|
(void) dictinsert(d, "AWCMP_STEREO", newintobject(AWCMP_STEREO));
|
|
|
|
(void) dictinsert(d, "AWCMP_JOINT_STEREO",
|
|
|
|
newintobject(AWCMP_JOINT_STEREO));
|
|
|
|
(void) dictinsert(d, "AWCMP_INDEPENDENT",
|
|
|
|
newintobject(AWCMP_INDEPENDENT));
|
|
|
|
(void) dictinsert(d, "AWCMP_FIXED_RATE",
|
|
|
|
newintobject(AWCMP_FIXED_RATE));
|
|
|
|
(void) dictinsert(d, "AWCMP_CONST_QUAL",
|
|
|
|
newintobject(AWCMP_CONST_QUAL));
|
|
|
|
(void) dictinsert(d, "AWCMP_LOSSLESS", newintobject(AWCMP_LOSSLESS));
|
|
|
|
(void) dictinsert(d, "AWCMP_MPEG_LAYER_I",
|
|
|
|
newintobject(AWCMP_MPEG_LAYER_I));
|
|
|
|
(void) dictinsert(d, "AWCMP_MPEG_LAYER_II",
|
|
|
|
newintobject(AWCMP_MPEG_LAYER_II));
|
|
|
|
(void) dictinsert(d, "HEADER_START_CODE",
|
|
|
|
newintobject(CL_HEADER_START_CODE));
|
|
|
|
(void) dictinsert(d, "BAD_NO_BUFFERSPACE",
|
|
|
|
newintobject(CL_BAD_NO_BUFFERSPACE));
|
|
|
|
(void) dictinsert(d, "BAD_PVBUFFER", newintobject(CL_BAD_PVBUFFER));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFERLENGTH_NEG",
|
|
|
|
newintobject(CL_BAD_BUFFERLENGTH_NEG));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFERLENGTH_ODD",
|
|
|
|
newintobject(CL_BAD_BUFFERLENGTH_ODD));
|
|
|
|
(void) dictinsert(d, "BAD_PARAM", newintobject(CL_BAD_PARAM));
|
|
|
|
(void) dictinsert(d, "BAD_COMPRESSION_SCHEME",
|
|
|
|
newintobject(CL_BAD_COMPRESSION_SCHEME));
|
|
|
|
(void) dictinsert(d, "BAD_COMPRESSOR_HANDLE",
|
|
|
|
newintobject(CL_BAD_COMPRESSOR_HANDLE));
|
|
|
|
(void) dictinsert(d, "BAD_COMPRESSOR_HANDLE_POINTER",
|
|
|
|
newintobject(CL_BAD_COMPRESSOR_HANDLE_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_HANDLE",
|
|
|
|
newintobject(CL_BAD_BUFFER_HANDLE));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_QUERY_SIZE",
|
|
|
|
newintobject(CL_BAD_BUFFER_QUERY_SIZE));
|
|
|
|
(void) dictinsert(d, "JPEG_ERROR", newintobject(CL_JPEG_ERROR));
|
|
|
|
(void) dictinsert(d, "BAD_FRAME_SIZE",
|
|
|
|
newintobject(CL_BAD_FRAME_SIZE));
|
|
|
|
(void) dictinsert(d, "PARAM_OUT_OF_RANGE",
|
|
|
|
newintobject(CL_PARAM_OUT_OF_RANGE));
|
|
|
|
(void) dictinsert(d, "ADDED_ALGORITHM_ERROR",
|
|
|
|
newintobject(CL_ADDED_ALGORITHM_ERROR));
|
|
|
|
(void) dictinsert(d, "BAD_ALGORITHM_TYPE",
|
|
|
|
newintobject(CL_BAD_ALGORITHM_TYPE));
|
|
|
|
(void) dictinsert(d, "BAD_ALGORITHM_NAME",
|
|
|
|
newintobject(CL_BAD_ALGORITHM_NAME));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFERING", newintobject(CL_BAD_BUFFERING));
|
|
|
|
(void) dictinsert(d, "BUFFER_NOT_CREATED",
|
|
|
|
newintobject(CL_BUFFER_NOT_CREATED));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_EXISTS",
|
|
|
|
newintobject(CL_BAD_BUFFER_EXISTS));
|
|
|
|
(void) dictinsert(d, "BAD_INTERNAL_FORMAT",
|
|
|
|
newintobject(CL_BAD_INTERNAL_FORMAT));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_POINTER",
|
|
|
|
newintobject(CL_BAD_BUFFER_POINTER));
|
|
|
|
(void) dictinsert(d, "FRAME_BUFFER_SIZE_ZERO",
|
|
|
|
newintobject(CL_FRAME_BUFFER_SIZE_ZERO));
|
|
|
|
(void) dictinsert(d, "BAD_STREAM_HEADER",
|
|
|
|
newintobject(CL_BAD_STREAM_HEADER));
|
|
|
|
(void) dictinsert(d, "BAD_LICENSE", newintobject(CL_BAD_LICENSE));
|
|
|
|
(void) dictinsert(d, "AWARE_ERROR", newintobject(CL_AWARE_ERROR));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_SIZE_POINTER",
|
|
|
|
newintobject(CL_BAD_BUFFER_SIZE_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_SIZE",
|
|
|
|
newintobject(CL_BAD_BUFFER_SIZE));
|
|
|
|
(void) dictinsert(d, "BAD_BUFFER_TYPE",
|
|
|
|
newintobject(CL_BAD_BUFFER_TYPE));
|
|
|
|
(void) dictinsert(d, "BAD_HEADER_SIZE",
|
|
|
|
newintobject(CL_BAD_HEADER_SIZE));
|
|
|
|
(void) dictinsert(d, "BAD_FUNCTION_POINTER",
|
|
|
|
newintobject(CL_BAD_FUNCTION_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_SCHEME_POINTER",
|
|
|
|
newintobject(CL_BAD_SCHEME_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_STRING_POINTER",
|
|
|
|
newintobject(CL_BAD_STRING_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_MIN_GT_MAX",
|
|
|
|
newintobject(CL_BAD_MIN_GT_MAX));
|
|
|
|
(void) dictinsert(d, "BAD_INITIAL_VALUE",
|
|
|
|
newintobject(CL_BAD_INITIAL_VALUE));
|
|
|
|
(void) dictinsert(d, "BAD_PARAM_ID_POINTER",
|
|
|
|
newintobject(CL_BAD_PARAM_ID_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_PARAM_TYPE",
|
|
|
|
newintobject(CL_BAD_PARAM_TYPE));
|
|
|
|
(void) dictinsert(d, "BAD_TEXT_STRING_PTR",
|
|
|
|
newintobject(CL_BAD_TEXT_STRING_PTR));
|
|
|
|
(void) dictinsert(d, "BAD_FUNCTIONALITY",
|
|
|
|
newintobject(CL_BAD_FUNCTIONALITY));
|
|
|
|
(void) dictinsert(d, "BAD_NUMBER_OF_BLOCKS",
|
|
|
|
newintobject(CL_BAD_NUMBER_OF_BLOCKS));
|
|
|
|
(void) dictinsert(d, "BAD_BLOCK_SIZE",
|
|
|
|
newintobject(CL_BAD_BLOCK_SIZE));
|
|
|
|
(void) dictinsert(d, "BAD_POINTER", newintobject(CL_BAD_POINTER));
|
|
|
|
(void) dictinsert(d, "BAD_BOARD", newintobject(CL_BAD_BOARD));
|
|
|
|
(void) dictinsert(d, "MVC2_ERROR", newintobject(CL_MVC2_ERROR));
|
|
|
|
#ifdef IRIX_5_3_LIBRARY
|
|
|
|
(void) dictinsert(d, "NEXT_NOT_AVAILABLE",
|
|
|
|
newintobject(CL_NEXT_NOT_AVAILABLE));
|
|
|
|
(void) dictinsert(d, "SCHEME_BUSY", newintobject(CL_SCHEME_BUSY));
|
|
|
|
(void) dictinsert(d, "SCHEME_NOT_AVAILABLE",
|
|
|
|
newintobject(CL_SCHEME_NOT_AVAILABLE));
|
|
|
|
#endif
|
|
|
|
#ifdef CL_LUMA_THRESHOLD
|
|
|
|
/* backward compatibility */
|
|
|
|
(void) dictinsert(d, "LUMA_THRESHOLD",
|
|
|
|
newintobject(CL_LUMA_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "CHROMA_THRESHOLD",
|
|
|
|
newintobject(CL_CHROMA_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "EDGE_THRESHOLD",
|
|
|
|
newintobject(CL_EDGE_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "BLENDING", newintobject(CL_BLENDING));
|
|
|
|
(void) dictinsert(d, "QUALITY_FACTOR",
|
|
|
|
newintobject(CL_QUALITY_FACTOR));
|
|
|
|
(void) dictinsert(d, "STREAM_HEADERS",
|
|
|
|
newintobject(CL_STREAM_HEADERS));
|
|
|
|
(void) dictinsert(d, "QUALITY_LEVEL", newintobject(CL_QUALITY_LEVEL));
|
|
|
|
(void) dictinsert(d, "TILE_THRESHOLD",
|
|
|
|
newintobject(CL_TILE_THRESHOLD));
|
|
|
|
(void) dictinsert(d, "SAMPLES_PER_TILE",
|
|
|
|
newintobject(CL_SAMPLES_PER_TILE));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (err_occurred())
|
|
|
|
fatal("can't initialize module cl");
|
1992-09-24 07:37:39 -03:00
|
|
|
|
|
|
|
(void) clSetErrorHandler(cl_ErrorHandler);
|
1992-09-23 11:53:00 -03:00
|
|
|
}
|