CL.py, clmodule.c: Adapted to new CL library. Lots of new methods.
aifc.py: Several small improvements. Use new methods from CL module.
This commit is contained in:
parent
8d733a00f0
commit
3a997279d5
39
Lib/aifc.py
39
Lib/aifc.py
|
@ -356,6 +356,7 @@ class Aifc_read():
|
||||||
# _ssnd_seek_needed -- 1 iff positioned correctly in audio
|
# _ssnd_seek_needed -- 1 iff positioned correctly in audio
|
||||||
# file for readframes()
|
# file for readframes()
|
||||||
# _ssnd_chunk -- instantiation of a chunk class for the SSND chunk
|
# _ssnd_chunk -- instantiation of a chunk class for the SSND chunk
|
||||||
|
# _framesize -- size of one frame in the file
|
||||||
def initfp(self, file):
|
def initfp(self, file):
|
||||||
self._file = file
|
self._file = file
|
||||||
self._version = 0
|
self._version = 0
|
||||||
|
@ -497,24 +498,15 @@ class Aifc_read():
|
||||||
if self._ssnd_seek_needed:
|
if self._ssnd_seek_needed:
|
||||||
self._ssnd_chunk.rewind()
|
self._ssnd_chunk.rewind()
|
||||||
dummy = self._ssnd_chunk.read(8)
|
dummy = self._ssnd_chunk.read(8)
|
||||||
pos = self._soundpos * self._nchannels * self._sampwidth
|
pos = self._soundpos * self._framesize
|
||||||
if self._decomp:
|
|
||||||
if self._comptype in ('ULAW', 'ALAW'):
|
|
||||||
pos = pos / 2
|
|
||||||
if pos:
|
if pos:
|
||||||
self._ssnd_chunk.setpos(pos + 8)
|
self._ssnd_chunk.setpos(pos + 8)
|
||||||
self._ssnd_seek_needed = 0
|
self._ssnd_seek_needed = 0
|
||||||
if nframes == 0:
|
if nframes == 0:
|
||||||
return ''
|
return ''
|
||||||
size = nframes * self._nchannels * self._sampwidth
|
data = self._ssnd_chunk.read(nframes * self._framesize)
|
||||||
if self._decomp:
|
|
||||||
if self._comptype in ('ULAW', 'ALAW'):
|
|
||||||
size = size / 2
|
|
||||||
data = self._ssnd_chunk.read(size)
|
|
||||||
if self._decomp and data:
|
if self._decomp and data:
|
||||||
params = [CL.FRAME_BUFFER_SIZE, len(data) * 2, \
|
self._decomp.SetParam(CL.FRAME_BUFFER_SIZE, len(data) * 2)
|
||||||
CL.COMPRESSED_BUFFER_SIZE, len(data)]
|
|
||||||
self._decomp.SetParams(params)
|
|
||||||
data = self._decomp.Decompress(len(data) / self._nchannels, data)
|
data = self._decomp.Decompress(len(data) / self._nchannels, data)
|
||||||
self._soundpos = self._soundpos + len(data) / (self._nchannels * self._sampwidth)
|
self._soundpos = self._soundpos + len(data) / (self._nchannels * self._sampwidth)
|
||||||
return data
|
return data
|
||||||
|
@ -530,6 +522,7 @@ class Aifc_read():
|
||||||
self._sampwidth = _convert1(sampwidth, _sampwidthlist)
|
self._sampwidth = _convert1(sampwidth, _sampwidthlist)
|
||||||
framerate = _read_float(chunk)
|
framerate = _read_float(chunk)
|
||||||
self._framerate = _convert1(framerate, _frameratelist)
|
self._framerate = _convert1(framerate, _frameratelist)
|
||||||
|
self._framesize = self._nchannels * self._sampwidth
|
||||||
if self._aifc:
|
if self._aifc:
|
||||||
#DEBUG: SGI's soundeditor produces a bad size :-(
|
#DEBUG: SGI's soundeditor produces a bad size :-(
|
||||||
kludge = 0
|
kludge = 0
|
||||||
|
@ -555,8 +548,10 @@ class Aifc_read():
|
||||||
raise Error, 'cannot read compressed AIFF-C files'
|
raise Error, 'cannot read compressed AIFF-C files'
|
||||||
if self._comptype == 'ULAW':
|
if self._comptype == 'ULAW':
|
||||||
scheme = CL.G711_ULAW
|
scheme = CL.G711_ULAW
|
||||||
|
self._framesize = self._framesize / 2
|
||||||
elif self._comptype == 'ALAW':
|
elif self._comptype == 'ALAW':
|
||||||
scheme = CL.G711_ALAW
|
scheme = CL.G711_ALAW
|
||||||
|
self._framesize = self._framesize / 2
|
||||||
else:
|
else:
|
||||||
raise Error, 'unsupported compression type'
|
raise Error, 'unsupported compression type'
|
||||||
self._decomp = cl.OpenDecompressor(scheme)
|
self._decomp = cl.OpenDecompressor(scheme)
|
||||||
|
@ -643,6 +638,7 @@ class Aifc_write():
|
||||||
def setnchannels(self, nchannels):
|
def setnchannels(self, nchannels):
|
||||||
if self._nframeswritten:
|
if self._nframeswritten:
|
||||||
raise Error, 'cannot change parameters after starting to write'
|
raise Error, 'cannot change parameters after starting to write'
|
||||||
|
dummy = _convert(nchannels, _nchannelslist)
|
||||||
self._nchannels = nchannels
|
self._nchannels = nchannels
|
||||||
|
|
||||||
def getnchannels(self):
|
def getnchannels(self):
|
||||||
|
@ -653,6 +649,7 @@ class Aifc_write():
|
||||||
def setsampwidth(self, sampwidth):
|
def setsampwidth(self, sampwidth):
|
||||||
if self._nframeswritten:
|
if self._nframeswritten:
|
||||||
raise Error, 'cannot change parameters after starting to write'
|
raise Error, 'cannot change parameters after starting to write'
|
||||||
|
dummy = _convert2(sampwidth, _sampwidthlist)
|
||||||
self._sampwidth = sampwidth
|
self._sampwidth = sampwidth
|
||||||
|
|
||||||
def getsampwidth(self):
|
def getsampwidth(self):
|
||||||
|
@ -663,6 +660,7 @@ class Aifc_write():
|
||||||
def setframerate(self, framerate):
|
def setframerate(self, framerate):
|
||||||
if self._nframeswritten:
|
if self._nframeswritten:
|
||||||
raise Error, 'cannot change parameters after starting to write'
|
raise Error, 'cannot change parameters after starting to write'
|
||||||
|
dummy = _convert2(framerate, _frameratelist)
|
||||||
self._framerate = framerate
|
self._framerate = framerate
|
||||||
|
|
||||||
def getframerate(self):
|
def getframerate(self):
|
||||||
|
@ -702,6 +700,9 @@ class Aifc_write():
|
||||||
raise Error, 'cannot change parameters after starting to write'
|
raise Error, 'cannot change parameters after starting to write'
|
||||||
if comptype not in ('NONE', 'ULAW', 'ALAW'):
|
if comptype not in ('NONE', 'ULAW', 'ALAW'):
|
||||||
raise Error, 'unsupported compression type'
|
raise Error, 'unsupported compression type'
|
||||||
|
dummy = _convert2(nchannels, _nchannelslist)
|
||||||
|
dummy = _convert2(sampwidth, _sampwidthlist)
|
||||||
|
dummy = _convert2(framerate, _frameratelist)
|
||||||
self._nchannels = nchannels
|
self._nchannels = nchannels
|
||||||
self._sampwidth = sampwidth
|
self._sampwidth = sampwidth
|
||||||
self._framerate = framerate
|
self._framerate = framerate
|
||||||
|
@ -755,9 +756,9 @@ class Aifc_write():
|
||||||
self._write_header(len(data))
|
self._write_header(len(data))
|
||||||
nframes = len(data) / (self._sampwidth * self._nchannels)
|
nframes = len(data) / (self._sampwidth * self._nchannels)
|
||||||
if self._comp:
|
if self._comp:
|
||||||
params = [CL.FRAME_BUFFER_SIZE, len(data), \
|
self._comp.SetParam(CL.FRAME_BUFFER_SIZE, len(data))
|
||||||
CL.COMPRESSED_BUFFER_SIZE, len(data)]
|
self._comp.SetParam(CL.COMPRESSED_BUFFER_SIZE, \
|
||||||
self._comp.SetParams(params)
|
len(data))
|
||||||
data = self._comp.Compress(nframes, data)
|
data = self._comp.Compress(nframes, data)
|
||||||
self._file.write(data)
|
self._file.write(data)
|
||||||
self._nframeswritten = self._nframeswritten + nframes
|
self._nframeswritten = self._nframeswritten + nframes
|
||||||
|
@ -803,7 +804,9 @@ class Aifc_write():
|
||||||
self._comp = cl.OpenCompressor(scheme)
|
self._comp = cl.OpenCompressor(scheme)
|
||||||
params = [CL.ORIGINAL_FORMAT, 0, \
|
params = [CL.ORIGINAL_FORMAT, 0, \
|
||||||
CL.BITS_PER_COMPONENT, 0, \
|
CL.BITS_PER_COMPONENT, 0, \
|
||||||
CL.FRAME_RATE, self._framerate]
|
CL.FRAME_RATE, self._framerate, \
|
||||||
|
CL.FRAME_BUFFER_SIZE, 100, \
|
||||||
|
CL.COMPRESSED_BUFFER_SIZE, 100]
|
||||||
if self._nchannels == AL.MONO:
|
if self._nchannels == AL.MONO:
|
||||||
params[1] = CL.MONO
|
params[1] = CL.MONO
|
||||||
else:
|
else:
|
||||||
|
@ -815,6 +818,8 @@ class Aifc_write():
|
||||||
else:
|
else:
|
||||||
params[3] = 24
|
params[3] = 24
|
||||||
self._comp.SetParams(params)
|
self._comp.SetParams(params)
|
||||||
|
# the compressor produces a header which we ignore
|
||||||
|
dummy = self._comp.Compress(0, '')
|
||||||
self._file.write('FORM')
|
self._file.write('FORM')
|
||||||
if not self._nframes:
|
if not self._nframes:
|
||||||
self._nframes = initlength / (self._nchannels * self._sampwidth)
|
self._nframes = initlength / (self._nchannels * self._sampwidth)
|
||||||
|
@ -836,7 +841,7 @@ class Aifc_write():
|
||||||
self._file.write('AIFF')
|
self._file.write('AIFF')
|
||||||
self._file.write('COMM')
|
self._file.write('COMM')
|
||||||
_write_long(self._file, commlength)
|
_write_long(self._file, commlength)
|
||||||
_write_short(self._file, self._nchannels)
|
_write_short(self._file, _convert2(self._nchannels, _nchannelslist))
|
||||||
self._nframes_pos = self._file.tell()
|
self._nframes_pos = self._file.tell()
|
||||||
_write_long(self._file, self._nframes)
|
_write_long(self._file, self._nframes)
|
||||||
_write_short(self._file, _convert2(self._sampwidth, _sampwidthlist))
|
_write_short(self._file, _convert2(self._sampwidth, _sampwidthlist))
|
||||||
|
|
322
Lib/irix5/CL.py
322
Lib/irix5/CL.py
|
@ -1,17 +1,18 @@
|
||||||
#
|
#
|
||||||
# cl.h - Compression Library typedefs and prototypes
|
# cl.h - Compression Library typedefs and prototypes
|
||||||
#
|
#
|
||||||
|
# 01/07/92 Cleanup by Brian Knittel
|
||||||
# 02/18/92 Original Version by Brian Knittel
|
# 02/18/92 Original Version by Brian Knittel
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# originalFormat parameter values
|
# originalFormat parameter values
|
||||||
#
|
#
|
||||||
MAX_NUMBER_OF_ORIGINAL_FORMATS = (32)
|
MAX_NUMBER_OF_ORIGINAL_FORMATS = 32
|
||||||
|
|
||||||
# Audio
|
# Audio
|
||||||
MONO = (0)
|
MONO = 0
|
||||||
STEREO_INTERLEAVED = (1)
|
STEREO_INTERLEAVED = 1
|
||||||
|
|
||||||
# Video
|
# Video
|
||||||
# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
|
# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
|
||||||
|
@ -21,152 +22,215 @@ STEREO_INTERLEAVED = (1)
|
||||||
# vertically in addition to horizontally, and is packed the same as
|
# vertically in addition to horizontally, and is packed the same as
|
||||||
# 422 except that U & V are not valid on the second line.
|
# 422 except that U & V are not valid on the second line.
|
||||||
#
|
#
|
||||||
RGB = (0)
|
RGB = 0
|
||||||
RGBX = (1)
|
RGBX = 1
|
||||||
RGBA = (2)
|
RGBA = 2
|
||||||
RGB332 = (3)
|
RGB332 = 3
|
||||||
|
|
||||||
GRAYSCALE = (4)
|
GRAYSCALE = 4
|
||||||
Y = (4)
|
Y = 4
|
||||||
YUV = (5)
|
YUV = 5
|
||||||
YCbCr = (5)
|
YCbCr = 5
|
||||||
YUV422 = (6) # 4:2:2 sampling
|
YUV422 = 6 # 4:2:2 sampling
|
||||||
YCbCr422 = (6) # 4:2:2 sampling
|
YCbCr422 = 6 # 4:2:2 sampling
|
||||||
YUV422HC = (7) # 4:1:1 sampling
|
YUV422HC = 7 # 4:1:1 sampling
|
||||||
YCbCr422HC = (7) # 4:1:1 sampling
|
YCbCr422HC = 7 # 4:1:1 sampling
|
||||||
|
YUV422DC = 7 # 4:1:1 sampling
|
||||||
|
YCbCr422DC = 7 # 4:1:1 sampling
|
||||||
|
|
||||||
MAX_NUMBER_OF_AUDIO_ALGORITHMS = (32)
|
BEST_FIT = -1
|
||||||
MAX_NUMBER_OF_VIDEO_ALGORITHMS = (32)
|
|
||||||
|
|
||||||
#
|
def BytesPerSample(s):
|
||||||
# "compressionScheme" argument values
|
if s in (MONO, YUV):
|
||||||
#
|
return 2
|
||||||
UNCOMPRESSED_AUDIO = (0)
|
elif s == STEREO_INTERLEAVED:
|
||||||
G711_ULAW = (1)
|
return 4
|
||||||
ULAW = (1)
|
else:
|
||||||
G711_ALAW = (2)
|
return 0
|
||||||
ALAW = (2)
|
|
||||||
G722 = (3)
|
|
||||||
|
|
||||||
UNCOMPRESSED = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 0)
|
def BytesPerPixel(f):
|
||||||
UNCOMPRESSED_VIDEO = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 0)
|
if f in (RGB, YUV):
|
||||||
RLE = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 1)
|
return 3
|
||||||
JPEG = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 2)
|
elif f in (RGBX, RGBA):
|
||||||
MPEG_VIDEO = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 3)
|
return 4
|
||||||
MVC1 = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 4)
|
elif f in (RGB332, GRAYSCALE):
|
||||||
RTR = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 5)
|
return 1
|
||||||
RTR1 = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 5)
|
else:
|
||||||
|
return 2
|
||||||
|
|
||||||
#
|
def AudioFormatName(f):
|
||||||
# Parameters
|
if f == MONO:
|
||||||
#
|
return 'MONO'
|
||||||
MAX_NUMBER_OF_PARAMS = (256)
|
elif f == STEREO_INTERLEAVED:
|
||||||
# Default Parameters
|
return 'STEREO_INTERLEAVED'
|
||||||
IMAGE_WIDTH = (0)
|
else:
|
||||||
IMAGE_HEIGHT = (1)
|
return 'Not a valid format'
|
||||||
ORIGINAL_FORMAT = (2)
|
|
||||||
INTERNAL_FORMAT = (3)
|
|
||||||
COMPONENTS = (4)
|
|
||||||
BITS_PER_COMPONENT = (5)
|
|
||||||
FRAME_RATE = (6)
|
|
||||||
COMPRESSION_RATIO = (7)
|
|
||||||
EXACT_COMPRESSION_RATIO = (8)
|
|
||||||
FRAME_BUFFER_SIZE = (9)
|
|
||||||
COMPRESSED_BUFFER_SIZE = (10)
|
|
||||||
BLOCK_SIZE = (11)
|
|
||||||
PREROLL = (12)
|
|
||||||
UNIQUE = (13)
|
|
||||||
FRAME_TYPE = (14)
|
|
||||||
OVERWRITE_MODE = (15)
|
|
||||||
NUMBER_OF_PARAMS = (16)
|
|
||||||
|
|
||||||
# JPEG Specific Parameters
|
def VideoFormatName(f):
|
||||||
QUALITY_FACTOR = (NUMBER_OF_PARAMS + 0)
|
if f == RGB:
|
||||||
|
return 'RGB'
|
||||||
|
elif f == RGBX:
|
||||||
|
return 'RGBX'
|
||||||
|
elif f == RGBA:
|
||||||
|
return 'RGBA'
|
||||||
|
elif f == RGB332:
|
||||||
|
return 'RGB332'
|
||||||
|
elif f == GRAYSCALE:
|
||||||
|
return 'GRAYSCALE'
|
||||||
|
elif f == YUV:
|
||||||
|
return 'YUV'
|
||||||
|
elif f == YUV422:
|
||||||
|
return 'YUV422'
|
||||||
|
elif f == YUV422DC:
|
||||||
|
return 'YUV422DC'
|
||||||
|
else:
|
||||||
|
return 'Not a valid format'
|
||||||
|
|
||||||
# MPEG Specific Parameters
|
MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32
|
||||||
SPEED = (NUMBER_OF_PARAMS + 0)
|
MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32
|
||||||
ACTUAL_FRAME_INDEX = (NUMBER_OF_PARAMS + 1)
|
|
||||||
|
|
||||||
# RTR Specific Parameters
|
|
||||||
QUALITY_LEVEL = (NUMBER_OF_PARAMS + 0)
|
|
||||||
|
|
||||||
# #define clTypeIsFloat(v) (*(float *)&(v))
|
|
||||||
# #define clTypeIsLong(v) (*(long *)&(v))
|
|
||||||
#
|
|
||||||
# RATIO_1 = (65536.0)
|
|
||||||
# #define clFloatToRatio(f) ((long)((float)(f) * RATIO_1))
|
|
||||||
# #define clRatioToFloat(f) ((float)(f) / RATIO_1)
|
|
||||||
# RATIO_SHIFT = (16)
|
|
||||||
# #define clRatioMul(m, r) ((m) * (r))
|
|
||||||
# #define clRatioToLong(r) ((r) >> RATIO_SHIFT)
|
|
||||||
# #define clLongToRatio(r) ((r) << RATIO_SHIFT)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Parameter value types
|
|
||||||
#
|
|
||||||
ENUM_VALUE = (0) # only certain constant values are valid
|
|
||||||
RANGE_VALUE = (1) # any value in a given range is valid
|
|
||||||
FLOATING_ENUM_VALUE = (2) # only certain constant floating point values are valid
|
|
||||||
FLOATING_RANGE_VALUE = (3) # any value in a given floating point range is valid
|
|
||||||
POINTER = (4) # any legal pointer is valid
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Algorithm types
|
# Algorithm types
|
||||||
#
|
#
|
||||||
AUDIO = (0)
|
AUDIO = 0
|
||||||
VIDEO = (1)
|
VIDEO = 1
|
||||||
|
|
||||||
|
def AlgorithmNumber(scheme):
|
||||||
|
return scheme & 0x7fff
|
||||||
|
def AlgorithmType(scheme):
|
||||||
|
return (scheme >> 15) & 1
|
||||||
|
def Algorithm(type, n):
|
||||||
|
return n | ((type & 1) << 15)
|
||||||
|
|
||||||
|
#
|
||||||
|
# "compressionScheme" argument values
|
||||||
|
#
|
||||||
|
UNKNOWN_SCHEME = -1
|
||||||
|
|
||||||
|
UNCOMPRESSED_AUDIO = Algorithm(AUDIO, 0)
|
||||||
|
G711_ULAW = Algorithm(AUDIO, 1)
|
||||||
|
ULAW = Algorithm(AUDIO, 1)
|
||||||
|
G711_ALAW = Algorithm(AUDIO, 2)
|
||||||
|
ALAW = Algorithm(AUDIO, 2)
|
||||||
|
AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3)
|
||||||
|
AWARE_MULTIRATE = Algorithm(AUDIO, 4)
|
||||||
|
|
||||||
|
UNCOMPRESSED = Algorithm(VIDEO, 0)
|
||||||
|
UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0)
|
||||||
|
RLE = Algorithm(VIDEO, 1)
|
||||||
|
JPEG = Algorithm(VIDEO, 2)
|
||||||
|
MPEG_VIDEO = Algorithm(VIDEO, 3)
|
||||||
|
MVC1 = Algorithm(VIDEO, 4)
|
||||||
|
RTR = Algorithm(VIDEO, 5)
|
||||||
|
RTR1 = Algorithm(VIDEO, 5)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parameters
|
||||||
|
#
|
||||||
|
MAX_NUMBER_OF_PARAMS = 256
|
||||||
|
# Default Parameters
|
||||||
|
IMAGE_WIDTH = 0
|
||||||
|
IMAGE_HEIGHT = 1
|
||||||
|
ORIGINAL_FORMAT = 2
|
||||||
|
INTERNAL_FORMAT = 3
|
||||||
|
COMPONENTS = 4
|
||||||
|
BITS_PER_COMPONENT = 5
|
||||||
|
FRAME_RATE = 6
|
||||||
|
COMPRESSION_RATIO = 7
|
||||||
|
EXACT_COMPRESSION_RATIO = 8
|
||||||
|
FRAME_BUFFER_SIZE = 9
|
||||||
|
COMPRESSED_BUFFER_SIZE = 10
|
||||||
|
BLOCK_SIZE = 11
|
||||||
|
PREROLL = 12
|
||||||
|
FRAME_TYPE = 13
|
||||||
|
ALGORITHM_ID = 14
|
||||||
|
ALGORITHM_VERSION = 15
|
||||||
|
ORIENTATION = 16
|
||||||
|
NUMBER_OF_FRAMES = 17
|
||||||
|
SPEED = 18
|
||||||
|
LAST_FRAME_INDEX = 19
|
||||||
|
NUMBER_OF_PARAMS = 20
|
||||||
|
|
||||||
|
# JPEG Specific Parameters
|
||||||
|
QUALITY_FACTOR = NUMBER_OF_PARAMS + 0
|
||||||
|
|
||||||
|
# MPEG Specific Parameters
|
||||||
|
END_OF_SEQUENCE = NUMBER_OF_PARAMS + 0
|
||||||
|
|
||||||
|
# RTR Specific Parameters
|
||||||
|
QUALITY_LEVEL = NUMBER_OF_PARAMS + 0
|
||||||
|
ZOOM_X = NUMBER_OF_PARAMS + 1
|
||||||
|
ZOOM_Y = NUMBER_OF_PARAMS + 2
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parameter value types
|
||||||
|
#
|
||||||
|
ENUM_VALUE = 0 # only certain constant values are valid
|
||||||
|
RANGE_VALUE = 1 # any value in a given range is valid
|
||||||
|
FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid
|
||||||
|
FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid
|
||||||
|
|
||||||
#
|
#
|
||||||
# Algorithm Functionality
|
# Algorithm Functionality
|
||||||
#
|
#
|
||||||
DECOMPRESSOR = (1)
|
DECOMPRESSOR = 1
|
||||||
COMPRESSOR = (2)
|
COMPRESSOR = 2
|
||||||
CODEC = (3)
|
CODEC = 3
|
||||||
|
|
||||||
#
|
#
|
||||||
# Buffer types
|
# Buffer types
|
||||||
#
|
#
|
||||||
NONE = (0)
|
NONE = 0
|
||||||
FRAME = (1)
|
FRAME = 1
|
||||||
DATA = (2)
|
DATA = 2
|
||||||
|
|
||||||
|
#
|
||||||
|
# Frame types
|
||||||
|
#
|
||||||
|
NONE = 0
|
||||||
|
KEYFRAME = 1
|
||||||
|
INTRA = 1
|
||||||
|
PREDICTED = 2
|
||||||
|
BIDIRECTIONAL = 3
|
||||||
|
|
||||||
|
#
|
||||||
|
# Orientations
|
||||||
|
#
|
||||||
|
TOP_DOWN = 0
|
||||||
|
BOTTOM_UP = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# SGI Proprietaty Algorithm Header Start Code
|
||||||
|
#
|
||||||
|
HEADER_START_CODE = 0xc1C0DEC
|
||||||
|
|
||||||
#
|
#
|
||||||
# error codes
|
# error codes
|
||||||
#
|
#
|
||||||
BAD_NOT_IMPLEMENTED = ( -1) # not impimented yet
|
|
||||||
BAD_NO_BUFFERSPACE = ( -2) # no space for internal buffers
|
BAD_NO_BUFFERSPACE = -2 # no space for internal buffers
|
||||||
BAD_BUFFER_NULL = ( -3) # null buffer pointer
|
BAD_PVBUFFER = -3 # param/val buffer doesn't make sense
|
||||||
BAD_COUNT_NEG = ( -4) # negative count
|
BAD_BUFFERLENGTH_NEG = -4 # negative buffer length
|
||||||
BAD_PVBUFFER = ( -5) # param/val buffer doesn't make sense
|
BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer
|
||||||
BAD_BUFFERLENGTH_NEG = ( -6) # negative buffer length
|
BAD_PARAM = -6 # invalid parameter
|
||||||
BAD_BUFFERLENGTH_ODD = ( -7) # odd length parameter/value buffer
|
BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid
|
||||||
BAD_PARAM = ( -8) # invalid parameter
|
BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid
|
||||||
BAD_COMPRESSION_SCHEME = ( -9) # compression scheme parameter invalid
|
BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid
|
||||||
BAD_COMPRESSOR_HANDLE = (-10) # compression handle parameter invalid
|
BAD_BUFFER_HANDLE = -10 # buffer handle invalid
|
||||||
BAD_COMPRESSOR_HANDLE_POINTER = (-11) # compression handle pointer invalid
|
BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large
|
||||||
BAD_BUFFER_HANDLE = (-12) # callback function invalid
|
JPEG_ERROR = -12 # error from libjpeg
|
||||||
BAD_ALGORITHM_INFO = (-13) # algorithm info invalid
|
BAD_FRAME_SIZE = -13 # frame size invalid
|
||||||
BAD_CL_BAD_WIDTH_OR_HEIGHT = (-14) # compressor width or height invalid
|
PARAM_OUT_OF_RANGE = -14 # parameter out of range
|
||||||
BAD_POINTER_FROM_CALLBACK_FUNCTION = (-15) # pointer from callback invalid
|
ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error
|
||||||
JPEG_ERROR = (-16) # error from libjpeg
|
BAD_ALGORITHM_TYPE = -16 # bad algorithm type
|
||||||
NO_SEMAPHORE = (-17) # could not get semaphore
|
BAD_ALGORITHM_NAME = -17 # bad algorithm name
|
||||||
BAD_WIDTH_OR_HEIGHT = (-18) # width or height invalid
|
BAD_BUFFERING = -18 # bad buffering calls
|
||||||
BAD_FRAME_COUNT = (-19) # frame count invalid
|
BUFFER_NOT_CREATED = -19 # buffer not created
|
||||||
BAD_FRAME_INDEX = (-20) # frame index invalid
|
BAD_BUFFER_EXISTS = -20 # buffer already created
|
||||||
BAD_FRAME_BUFFER = (-21) # frame buffer pointer invalid
|
BAD_INTERNAL_FORMAT = -21 # invalid internal format
|
||||||
BAD_FRAME_SIZE = (-22) # frame size invalid
|
BAD_BUFFER_POINTER = -22 # invalid buffer pointer
|
||||||
BAD_DATA_BUFFER = (-23) # data buffer pointer invalid
|
FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size
|
||||||
BAD_DATA_SIZE = (-24) # data buffer size invalid
|
BAD_STREAM_HEADER = -24 # invalid stream header
|
||||||
BAD_TOTAL_NUMBER_OF_FRAMES = (-25) # total number of frames invalid
|
|
||||||
BAD_IMAGE_FORMAT = (-26) # image format invalid
|
BAD_LICENSE = -25 # netls license not valid
|
||||||
BAD_BITS_PER_COMPONENT = (-27) # bits per component invalid
|
AWARE_ERROR = -26 # error from libawcmp
|
||||||
BAD_FRAME_RATE = (-28) # frame rate invalid
|
|
||||||
BAD_INSUFFICIENT_DATA_FROM_CALLBACK_FUNCTION = (-29) # insufficient data from callback invalid
|
|
||||||
PARAM_OUT_OF_RANGE = (-30) # parameter out of range
|
|
||||||
ADDED_ALGORITHM_ERROR = (-31) # added algorithm had a unique error
|
|
||||||
BAD_ALGORITHM_TYPE = (-32) # bad algorithm type
|
|
||||||
BAD_ALGORITHM_NAME = (-33) # bad algorithm name
|
|
||||||
BAD_FRAME_INDEXING = (-34) # bad frame indexing
|
|
||||||
BAD_BUFFERING = (-35) # bad buffering calls
|
|
||||||
BUFFER_NOT_CREATED = (-36) # buffer not created
|
|
||||||
BAD_BUFFER_EXISTS = (-37) # buffer already created
|
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
#
|
#
|
||||||
# cl.h - Compression Library typedefs and prototypes
|
# cl.h - Compression Library typedefs and prototypes
|
||||||
#
|
#
|
||||||
|
# 01/07/92 Cleanup by Brian Knittel
|
||||||
# 02/18/92 Original Version by Brian Knittel
|
# 02/18/92 Original Version by Brian Knittel
|
||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# originalFormat parameter values
|
# originalFormat parameter values
|
||||||
#
|
#
|
||||||
MAX_NUMBER_OF_ORIGINAL_FORMATS = (32)
|
MAX_NUMBER_OF_ORIGINAL_FORMATS = 32
|
||||||
|
|
||||||
# Audio
|
# Audio
|
||||||
MONO = (0)
|
MONO = 0
|
||||||
STEREO_INTERLEAVED = (1)
|
STEREO_INTERLEAVED = 1
|
||||||
|
|
||||||
# Video
|
# Video
|
||||||
# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
|
# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
|
||||||
|
@ -21,152 +22,215 @@ STEREO_INTERLEAVED = (1)
|
||||||
# vertically in addition to horizontally, and is packed the same as
|
# vertically in addition to horizontally, and is packed the same as
|
||||||
# 422 except that U & V are not valid on the second line.
|
# 422 except that U & V are not valid on the second line.
|
||||||
#
|
#
|
||||||
RGB = (0)
|
RGB = 0
|
||||||
RGBX = (1)
|
RGBX = 1
|
||||||
RGBA = (2)
|
RGBA = 2
|
||||||
RGB332 = (3)
|
RGB332 = 3
|
||||||
|
|
||||||
GRAYSCALE = (4)
|
GRAYSCALE = 4
|
||||||
Y = (4)
|
Y = 4
|
||||||
YUV = (5)
|
YUV = 5
|
||||||
YCbCr = (5)
|
YCbCr = 5
|
||||||
YUV422 = (6) # 4:2:2 sampling
|
YUV422 = 6 # 4:2:2 sampling
|
||||||
YCbCr422 = (6) # 4:2:2 sampling
|
YCbCr422 = 6 # 4:2:2 sampling
|
||||||
YUV422HC = (7) # 4:1:1 sampling
|
YUV422HC = 7 # 4:1:1 sampling
|
||||||
YCbCr422HC = (7) # 4:1:1 sampling
|
YCbCr422HC = 7 # 4:1:1 sampling
|
||||||
|
YUV422DC = 7 # 4:1:1 sampling
|
||||||
|
YCbCr422DC = 7 # 4:1:1 sampling
|
||||||
|
|
||||||
MAX_NUMBER_OF_AUDIO_ALGORITHMS = (32)
|
BEST_FIT = -1
|
||||||
MAX_NUMBER_OF_VIDEO_ALGORITHMS = (32)
|
|
||||||
|
|
||||||
#
|
def BytesPerSample(s):
|
||||||
# "compressionScheme" argument values
|
if s in (MONO, YUV):
|
||||||
#
|
return 2
|
||||||
UNCOMPRESSED_AUDIO = (0)
|
elif s == STEREO_INTERLEAVED:
|
||||||
G711_ULAW = (1)
|
return 4
|
||||||
ULAW = (1)
|
else:
|
||||||
G711_ALAW = (2)
|
return 0
|
||||||
ALAW = (2)
|
|
||||||
G722 = (3)
|
|
||||||
|
|
||||||
UNCOMPRESSED = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 0)
|
def BytesPerPixel(f):
|
||||||
UNCOMPRESSED_VIDEO = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 0)
|
if f in (RGB, YUV):
|
||||||
RLE = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 1)
|
return 3
|
||||||
JPEG = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 2)
|
elif f in (RGBX, RGBA):
|
||||||
MPEG_VIDEO = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 3)
|
return 4
|
||||||
MVC1 = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 4)
|
elif f in (RGB332, GRAYSCALE):
|
||||||
RTR = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 5)
|
return 1
|
||||||
RTR1 = (MAX_NUMBER_OF_AUDIO_ALGORITHMS + 5)
|
else:
|
||||||
|
return 2
|
||||||
|
|
||||||
#
|
def AudioFormatName(f):
|
||||||
# Parameters
|
if f == MONO:
|
||||||
#
|
return 'MONO'
|
||||||
MAX_NUMBER_OF_PARAMS = (256)
|
elif f == STEREO_INTERLEAVED:
|
||||||
# Default Parameters
|
return 'STEREO_INTERLEAVED'
|
||||||
IMAGE_WIDTH = (0)
|
else:
|
||||||
IMAGE_HEIGHT = (1)
|
return 'Not a valid format'
|
||||||
ORIGINAL_FORMAT = (2)
|
|
||||||
INTERNAL_FORMAT = (3)
|
|
||||||
COMPONENTS = (4)
|
|
||||||
BITS_PER_COMPONENT = (5)
|
|
||||||
FRAME_RATE = (6)
|
|
||||||
COMPRESSION_RATIO = (7)
|
|
||||||
EXACT_COMPRESSION_RATIO = (8)
|
|
||||||
FRAME_BUFFER_SIZE = (9)
|
|
||||||
COMPRESSED_BUFFER_SIZE = (10)
|
|
||||||
BLOCK_SIZE = (11)
|
|
||||||
PREROLL = (12)
|
|
||||||
UNIQUE = (13)
|
|
||||||
FRAME_TYPE = (14)
|
|
||||||
OVERWRITE_MODE = (15)
|
|
||||||
NUMBER_OF_PARAMS = (16)
|
|
||||||
|
|
||||||
# JPEG Specific Parameters
|
def VideoFormatName(f):
|
||||||
QUALITY_FACTOR = (NUMBER_OF_PARAMS + 0)
|
if f == RGB:
|
||||||
|
return 'RGB'
|
||||||
|
elif f == RGBX:
|
||||||
|
return 'RGBX'
|
||||||
|
elif f == RGBA:
|
||||||
|
return 'RGBA'
|
||||||
|
elif f == RGB332:
|
||||||
|
return 'RGB332'
|
||||||
|
elif f == GRAYSCALE:
|
||||||
|
return 'GRAYSCALE'
|
||||||
|
elif f == YUV:
|
||||||
|
return 'YUV'
|
||||||
|
elif f == YUV422:
|
||||||
|
return 'YUV422'
|
||||||
|
elif f == YUV422DC:
|
||||||
|
return 'YUV422DC'
|
||||||
|
else:
|
||||||
|
return 'Not a valid format'
|
||||||
|
|
||||||
# MPEG Specific Parameters
|
MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32
|
||||||
SPEED = (NUMBER_OF_PARAMS + 0)
|
MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32
|
||||||
ACTUAL_FRAME_INDEX = (NUMBER_OF_PARAMS + 1)
|
|
||||||
|
|
||||||
# RTR Specific Parameters
|
|
||||||
QUALITY_LEVEL = (NUMBER_OF_PARAMS + 0)
|
|
||||||
|
|
||||||
# #define clTypeIsFloat(v) (*(float *)&(v))
|
|
||||||
# #define clTypeIsLong(v) (*(long *)&(v))
|
|
||||||
#
|
|
||||||
# RATIO_1 = (65536.0)
|
|
||||||
# #define clFloatToRatio(f) ((long)((float)(f) * RATIO_1))
|
|
||||||
# #define clRatioToFloat(f) ((float)(f) / RATIO_1)
|
|
||||||
# RATIO_SHIFT = (16)
|
|
||||||
# #define clRatioMul(m, r) ((m) * (r))
|
|
||||||
# #define clRatioToLong(r) ((r) >> RATIO_SHIFT)
|
|
||||||
# #define clLongToRatio(r) ((r) << RATIO_SHIFT)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Parameter value types
|
|
||||||
#
|
|
||||||
ENUM_VALUE = (0) # only certain constant values are valid
|
|
||||||
RANGE_VALUE = (1) # any value in a given range is valid
|
|
||||||
FLOATING_ENUM_VALUE = (2) # only certain constant floating point values are valid
|
|
||||||
FLOATING_RANGE_VALUE = (3) # any value in a given floating point range is valid
|
|
||||||
POINTER = (4) # any legal pointer is valid
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Algorithm types
|
# Algorithm types
|
||||||
#
|
#
|
||||||
AUDIO = (0)
|
AUDIO = 0
|
||||||
VIDEO = (1)
|
VIDEO = 1
|
||||||
|
|
||||||
|
def AlgorithmNumber(scheme):
|
||||||
|
return scheme & 0x7fff
|
||||||
|
def AlgorithmType(scheme):
|
||||||
|
return (scheme >> 15) & 1
|
||||||
|
def Algorithm(type, n):
|
||||||
|
return n | ((type & 1) << 15)
|
||||||
|
|
||||||
|
#
|
||||||
|
# "compressionScheme" argument values
|
||||||
|
#
|
||||||
|
UNKNOWN_SCHEME = -1
|
||||||
|
|
||||||
|
UNCOMPRESSED_AUDIO = Algorithm(AUDIO, 0)
|
||||||
|
G711_ULAW = Algorithm(AUDIO, 1)
|
||||||
|
ULAW = Algorithm(AUDIO, 1)
|
||||||
|
G711_ALAW = Algorithm(AUDIO, 2)
|
||||||
|
ALAW = Algorithm(AUDIO, 2)
|
||||||
|
AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3)
|
||||||
|
AWARE_MULTIRATE = Algorithm(AUDIO, 4)
|
||||||
|
|
||||||
|
UNCOMPRESSED = Algorithm(VIDEO, 0)
|
||||||
|
UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0)
|
||||||
|
RLE = Algorithm(VIDEO, 1)
|
||||||
|
JPEG = Algorithm(VIDEO, 2)
|
||||||
|
MPEG_VIDEO = Algorithm(VIDEO, 3)
|
||||||
|
MVC1 = Algorithm(VIDEO, 4)
|
||||||
|
RTR = Algorithm(VIDEO, 5)
|
||||||
|
RTR1 = Algorithm(VIDEO, 5)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parameters
|
||||||
|
#
|
||||||
|
MAX_NUMBER_OF_PARAMS = 256
|
||||||
|
# Default Parameters
|
||||||
|
IMAGE_WIDTH = 0
|
||||||
|
IMAGE_HEIGHT = 1
|
||||||
|
ORIGINAL_FORMAT = 2
|
||||||
|
INTERNAL_FORMAT = 3
|
||||||
|
COMPONENTS = 4
|
||||||
|
BITS_PER_COMPONENT = 5
|
||||||
|
FRAME_RATE = 6
|
||||||
|
COMPRESSION_RATIO = 7
|
||||||
|
EXACT_COMPRESSION_RATIO = 8
|
||||||
|
FRAME_BUFFER_SIZE = 9
|
||||||
|
COMPRESSED_BUFFER_SIZE = 10
|
||||||
|
BLOCK_SIZE = 11
|
||||||
|
PREROLL = 12
|
||||||
|
FRAME_TYPE = 13
|
||||||
|
ALGORITHM_ID = 14
|
||||||
|
ALGORITHM_VERSION = 15
|
||||||
|
ORIENTATION = 16
|
||||||
|
NUMBER_OF_FRAMES = 17
|
||||||
|
SPEED = 18
|
||||||
|
LAST_FRAME_INDEX = 19
|
||||||
|
NUMBER_OF_PARAMS = 20
|
||||||
|
|
||||||
|
# JPEG Specific Parameters
|
||||||
|
QUALITY_FACTOR = NUMBER_OF_PARAMS + 0
|
||||||
|
|
||||||
|
# MPEG Specific Parameters
|
||||||
|
END_OF_SEQUENCE = NUMBER_OF_PARAMS + 0
|
||||||
|
|
||||||
|
# RTR Specific Parameters
|
||||||
|
QUALITY_LEVEL = NUMBER_OF_PARAMS + 0
|
||||||
|
ZOOM_X = NUMBER_OF_PARAMS + 1
|
||||||
|
ZOOM_Y = NUMBER_OF_PARAMS + 2
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parameter value types
|
||||||
|
#
|
||||||
|
ENUM_VALUE = 0 # only certain constant values are valid
|
||||||
|
RANGE_VALUE = 1 # any value in a given range is valid
|
||||||
|
FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid
|
||||||
|
FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid
|
||||||
|
|
||||||
#
|
#
|
||||||
# Algorithm Functionality
|
# Algorithm Functionality
|
||||||
#
|
#
|
||||||
DECOMPRESSOR = (1)
|
DECOMPRESSOR = 1
|
||||||
COMPRESSOR = (2)
|
COMPRESSOR = 2
|
||||||
CODEC = (3)
|
CODEC = 3
|
||||||
|
|
||||||
#
|
#
|
||||||
# Buffer types
|
# Buffer types
|
||||||
#
|
#
|
||||||
NONE = (0)
|
NONE = 0
|
||||||
FRAME = (1)
|
FRAME = 1
|
||||||
DATA = (2)
|
DATA = 2
|
||||||
|
|
||||||
|
#
|
||||||
|
# Frame types
|
||||||
|
#
|
||||||
|
NONE = 0
|
||||||
|
KEYFRAME = 1
|
||||||
|
INTRA = 1
|
||||||
|
PREDICTED = 2
|
||||||
|
BIDIRECTIONAL = 3
|
||||||
|
|
||||||
|
#
|
||||||
|
# Orientations
|
||||||
|
#
|
||||||
|
TOP_DOWN = 0
|
||||||
|
BOTTOM_UP = 1
|
||||||
|
|
||||||
|
#
|
||||||
|
# SGI Proprietaty Algorithm Header Start Code
|
||||||
|
#
|
||||||
|
HEADER_START_CODE = 0xc1C0DEC
|
||||||
|
|
||||||
#
|
#
|
||||||
# error codes
|
# error codes
|
||||||
#
|
#
|
||||||
BAD_NOT_IMPLEMENTED = ( -1) # not impimented yet
|
|
||||||
BAD_NO_BUFFERSPACE = ( -2) # no space for internal buffers
|
BAD_NO_BUFFERSPACE = -2 # no space for internal buffers
|
||||||
BAD_BUFFER_NULL = ( -3) # null buffer pointer
|
BAD_PVBUFFER = -3 # param/val buffer doesn't make sense
|
||||||
BAD_COUNT_NEG = ( -4) # negative count
|
BAD_BUFFERLENGTH_NEG = -4 # negative buffer length
|
||||||
BAD_PVBUFFER = ( -5) # param/val buffer doesn't make sense
|
BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer
|
||||||
BAD_BUFFERLENGTH_NEG = ( -6) # negative buffer length
|
BAD_PARAM = -6 # invalid parameter
|
||||||
BAD_BUFFERLENGTH_ODD = ( -7) # odd length parameter/value buffer
|
BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid
|
||||||
BAD_PARAM = ( -8) # invalid parameter
|
BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid
|
||||||
BAD_COMPRESSION_SCHEME = ( -9) # compression scheme parameter invalid
|
BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid
|
||||||
BAD_COMPRESSOR_HANDLE = (-10) # compression handle parameter invalid
|
BAD_BUFFER_HANDLE = -10 # buffer handle invalid
|
||||||
BAD_COMPRESSOR_HANDLE_POINTER = (-11) # compression handle pointer invalid
|
BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large
|
||||||
BAD_BUFFER_HANDLE = (-12) # callback function invalid
|
JPEG_ERROR = -12 # error from libjpeg
|
||||||
BAD_ALGORITHM_INFO = (-13) # algorithm info invalid
|
BAD_FRAME_SIZE = -13 # frame size invalid
|
||||||
BAD_CL_BAD_WIDTH_OR_HEIGHT = (-14) # compressor width or height invalid
|
PARAM_OUT_OF_RANGE = -14 # parameter out of range
|
||||||
BAD_POINTER_FROM_CALLBACK_FUNCTION = (-15) # pointer from callback invalid
|
ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error
|
||||||
JPEG_ERROR = (-16) # error from libjpeg
|
BAD_ALGORITHM_TYPE = -16 # bad algorithm type
|
||||||
NO_SEMAPHORE = (-17) # could not get semaphore
|
BAD_ALGORITHM_NAME = -17 # bad algorithm name
|
||||||
BAD_WIDTH_OR_HEIGHT = (-18) # width or height invalid
|
BAD_BUFFERING = -18 # bad buffering calls
|
||||||
BAD_FRAME_COUNT = (-19) # frame count invalid
|
BUFFER_NOT_CREATED = -19 # buffer not created
|
||||||
BAD_FRAME_INDEX = (-20) # frame index invalid
|
BAD_BUFFER_EXISTS = -20 # buffer already created
|
||||||
BAD_FRAME_BUFFER = (-21) # frame buffer pointer invalid
|
BAD_INTERNAL_FORMAT = -21 # invalid internal format
|
||||||
BAD_FRAME_SIZE = (-22) # frame size invalid
|
BAD_BUFFER_POINTER = -22 # invalid buffer pointer
|
||||||
BAD_DATA_BUFFER = (-23) # data buffer pointer invalid
|
FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size
|
||||||
BAD_DATA_SIZE = (-24) # data buffer size invalid
|
BAD_STREAM_HEADER = -24 # invalid stream header
|
||||||
BAD_TOTAL_NUMBER_OF_FRAMES = (-25) # total number of frames invalid
|
|
||||||
BAD_IMAGE_FORMAT = (-26) # image format invalid
|
BAD_LICENSE = -25 # netls license not valid
|
||||||
BAD_BITS_PER_COMPONENT = (-27) # bits per component invalid
|
AWARE_ERROR = -26 # error from libawcmp
|
||||||
BAD_FRAME_RATE = (-28) # frame rate invalid
|
|
||||||
BAD_INSUFFICIENT_DATA_FROM_CALLBACK_FUNCTION = (-29) # insufficient data from callback invalid
|
|
||||||
PARAM_OUT_OF_RANGE = (-30) # parameter out of range
|
|
||||||
ADDED_ALGORITHM_ERROR = (-31) # added algorithm had a unique error
|
|
||||||
BAD_ALGORITHM_TYPE = (-32) # bad algorithm type
|
|
||||||
BAD_ALGORITHM_NAME = (-33) # bad algorithm name
|
|
||||||
BAD_FRAME_INDEXING = (-34) # bad frame indexing
|
|
||||||
BAD_BUFFERING = (-35) # bad buffering calls
|
|
||||||
BUFFER_NOT_CREATED = (-36) # buffer not created
|
|
||||||
BAD_BUFFER_EXISTS = (-37) # buffer already created
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ static int error_handler_called = 0;
|
||||||
Utility routines.
|
Utility routines.
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
static void
|
static void
|
||||||
cl_ErrorHandler(long errnum, const char *fmt, ...)
|
cl_ErrorHandler(CL_Handle handle, int code, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char errbuf[BUFSIZ]; /* hopefully big enough */
|
char errbuf[BUFSIZ]; /* hopefully big enough */
|
||||||
|
@ -68,10 +68,10 @@ cl_ErrorHandler(long errnum, const char *fmt, ...)
|
||||||
* This is not very efficient.
|
* This is not very efficient.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
param_type_is_float(CL_Handle comp, long param)
|
param_type_is_float(CL_Handle comp, int param)
|
||||||
{
|
{
|
||||||
long bufferlength;
|
int bufferlength;
|
||||||
long *PVbuffer;
|
int *PVbuffer;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
error_handler_called = 0;
|
error_handler_called = 0;
|
||||||
|
@ -82,7 +82,7 @@ param_type_is_float(CL_Handle comp, long param)
|
||||||
if (param < 0 || param >= bufferlength / 2)
|
if (param < 0 || param >= bufferlength / 2)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
PVbuffer = NEW(long, bufferlength);
|
PVbuffer = NEW(int, bufferlength);
|
||||||
if (PVbuffer == NULL)
|
if (PVbuffer == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -110,9 +110,9 @@ static object *
|
||||||
cl_CompressImage(self, args)
|
cl_CompressImage(self, args)
|
||||||
object *self, *args;
|
object *self, *args;
|
||||||
{
|
{
|
||||||
long compressionScheme, width, height, originalFormat;
|
int compressionScheme, width, height, originalFormat;
|
||||||
float compressionRatio;
|
float compressionRatio;
|
||||||
long frameBufferSize, compressedBufferSize;
|
int frameBufferSize, compressedBufferSize;
|
||||||
char *frameBuffer;
|
char *frameBuffer;
|
||||||
object *compressedBuffer;
|
object *compressedBuffer;
|
||||||
|
|
||||||
|
@ -156,9 +156,9 @@ static object *
|
||||||
cl_DecompressImage(self, args)
|
cl_DecompressImage(self, args)
|
||||||
object *self, *args;
|
object *self, *args;
|
||||||
{
|
{
|
||||||
long compressionScheme, width, height, originalFormat;
|
int compressionScheme, width, height, originalFormat;
|
||||||
char *compressedBuffer;
|
char *compressedBuffer;
|
||||||
long compressedBufferSize, frameBufferSize;
|
int compressedBufferSize, frameBufferSize;
|
||||||
object *frameBuffer;
|
object *frameBuffer;
|
||||||
|
|
||||||
if (!getargs(args, "(iiiis#i)", &compressionScheme, &width, &height,
|
if (!getargs(args, "(iiiis#i)", &compressionScheme, &width, &height,
|
||||||
|
@ -197,7 +197,7 @@ static object *
|
||||||
doClose(self, args, close_func)
|
doClose(self, args, close_func)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
long (*close_func) PROTO((CL_Handle));
|
int (*close_func) PROTO((CL_Handle));
|
||||||
{
|
{
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
|
||||||
|
@ -238,10 +238,10 @@ clm_Compress(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
long numberOfFrames;
|
int numberOfFrames;
|
||||||
long frameBufferSize, compressedBufferSize;
|
int frameBufferSize, compressedBufferSize;
|
||||||
char *frameBuffer;
|
char *frameBuffer;
|
||||||
long PVbuf[2];
|
int PVbuf[2];
|
||||||
object *data;
|
object *data;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
@ -291,11 +291,11 @@ clm_Decompress(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
long PVbuf[2];
|
int PVbuf[2];
|
||||||
object *data;
|
object *data;
|
||||||
long numberOfFrames;
|
int numberOfFrames;
|
||||||
char *compressedData;
|
char *compressedData;
|
||||||
long compressedDataSize;
|
int compressedDataSize;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
|
||||||
|
@ -331,13 +331,14 @@ static object *
|
||||||
doParams(self, args, func, modified)
|
doParams(self, args, func, modified)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
void (*func)(CL_Handle, long *, long);
|
void (*func)(CL_Handle, int *, int);
|
||||||
int modified;
|
int modified;
|
||||||
{
|
{
|
||||||
object *list, *v;
|
object *list, *v;
|
||||||
long *PVbuffer;
|
int *PVbuffer;
|
||||||
long length;
|
int length;
|
||||||
int i;
|
int i;
|
||||||
|
float number;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
|
||||||
|
@ -348,14 +349,15 @@ doParams(self, args, func, modified)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
length = getlistsize(list);
|
length = getlistsize(list);
|
||||||
PVbuffer = NEW(long, length);
|
PVbuffer = NEW(int, length);
|
||||||
if (PVbuffer == NULL)
|
if (PVbuffer == NULL)
|
||||||
return err_nomem();
|
return err_nomem();
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
v = getlistitem(list, i);
|
v = getlistitem(list, i);
|
||||||
if (is_floatobject(v))
|
if (is_floatobject(v)) {
|
||||||
PVbuffer[i] = clFloatToRatio(getfloatvalue(v));
|
number = getfloatvalue(v);
|
||||||
else if (is_intobject(v))
|
PVbuffer[i] = CL_TypeIsInt(number);
|
||||||
|
} else if (is_intobject(v))
|
||||||
PVbuffer[i] = getintvalue(v);
|
PVbuffer[i] = getintvalue(v);
|
||||||
else {
|
else {
|
||||||
DEL(PVbuffer);
|
DEL(PVbuffer);
|
||||||
|
@ -371,10 +373,12 @@ doParams(self, args, func, modified)
|
||||||
|
|
||||||
if (modified) {
|
if (modified) {
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
v = getlistitem(list, i);
|
if ((i & 1) &&
|
||||||
if (is_floatobject(v))
|
param_type_is_float(self->ob_compressorHdl,
|
||||||
v = newfloatobject(clRatioToFloat(PVbuffer[i]));
|
PVbuffer[i-1]) > 0) {
|
||||||
else
|
number = CL_TypeIsFloat(PVbuffer[i]);
|
||||||
|
v = newfloatobject(number);
|
||||||
|
} else
|
||||||
v = newintobject(PVbuffer[i]);
|
v = newintobject(PVbuffer[i]);
|
||||||
setlistitem(list, i, v);
|
setlistitem(list, i, v);
|
||||||
}
|
}
|
||||||
|
@ -399,7 +403,98 @@ clm_SetParams(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
return doParams(self, args, clSetParams, 1);
|
return doParams(self, args, clSetParams, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
do_get(self, args, func)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
int (*func)(CL_Handle, int);
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (param_type_is_float(self->ob_compressorHdl, paramID) > 0) {
|
||||||
|
fvalue = CL_TypeIsFloat(value);
|
||||||
|
return newfloatobject(fvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newintobject(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
clm_GetParam(self, args)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
return do_get(self, args, clGetParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
clm_GetDefault(self, args)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
return do_get(self, args, clGetDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
do_set(self, args, func)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
int (*func)(CL_Handle, int, int);
|
||||||
|
{
|
||||||
|
int paramID, value;
|
||||||
|
float fvalue;
|
||||||
|
|
||||||
|
CheckCompressor(self);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
error_handler_called = 0;
|
||||||
|
value = (*func)(self->ob_compressorHdl, paramID, value);
|
||||||
|
if (error_handler_called)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (param_type_is_float(self->ob_compressorHdl, paramID) > 0)
|
||||||
|
return newfloatobject(CL_TypeIsFloat(value));
|
||||||
|
else
|
||||||
|
return newintobject(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
clm_SetParam(self, args)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
return do_set(self, args, clSetParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
clm_SetDefault(self, args)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
return do_set(self, args, clSetDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
|
@ -408,7 +503,7 @@ clm_GetParamID(self, args)
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
long value;
|
int value;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
|
||||||
|
@ -431,8 +526,8 @@ clm_QueryParams(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
long bufferlength;
|
int bufferlength;
|
||||||
long *PVbuffer;
|
int *PVbuffer;
|
||||||
object *list;
|
object *list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -446,7 +541,7 @@ clm_QueryParams(self, args)
|
||||||
if (error_handler_called)
|
if (error_handler_called)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
PVbuffer = NEW(long, bufferlength);
|
PVbuffer = NEW(int, bufferlength);
|
||||||
if (PVbuffer == NULL)
|
if (PVbuffer == NULL)
|
||||||
return err_nomem();
|
return err_nomem();
|
||||||
|
|
||||||
|
@ -483,8 +578,8 @@ clm_GetMinMax(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
long param, min, max;
|
int param, min, max;
|
||||||
double fmin, fmax;
|
float fmin, fmax;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
|
||||||
|
@ -494,20 +589,36 @@ clm_GetMinMax(self, args)
|
||||||
clGetMinMax(self->ob_compressorHdl, param, &min, &max);
|
clGetMinMax(self->ob_compressorHdl, param, &min, &max);
|
||||||
|
|
||||||
if (param_type_is_float(self->ob_compressorHdl, param) > 0) {
|
if (param_type_is_float(self->ob_compressorHdl, param) > 0) {
|
||||||
fmin = clRatioToFloat(min);
|
fmin = CL_TypeIsFloat(min);
|
||||||
fmax = clRatioToFloat(max);
|
fmax = CL_TypeIsFloat(max);
|
||||||
return mkvalue("(ff)", fmin, fmax);
|
return mkvalue("(ff)", fmin, fmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mkvalue("(ii)", min, max);
|
return mkvalue("(ii)", min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
clm_SetMin(self, args)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
return do_set(self, args, clSetMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
clm_SetMax(self, args)
|
||||||
|
clobject *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
return do_set(self, args, clSetMax);
|
||||||
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
clm_GetName(self, args)
|
clm_GetName(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
long param;
|
int param;
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
@ -527,29 +638,20 @@ clm_GetName(self, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
clm_GetDefault(self, args)
|
clm_ReadHeader(self, args)
|
||||||
clobject *self;
|
clobject *self;
|
||||||
object *args;
|
object *args;
|
||||||
{
|
{
|
||||||
long param, value;
|
char *header;
|
||||||
double fvalue;
|
int headerSize;
|
||||||
|
|
||||||
CheckCompressor(self);
|
CheckCompressor(self);
|
||||||
|
|
||||||
if (!getargs(args, "i", ¶m))
|
if (!getargs(args, "s#", &header, &headerSize))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
error_handler_called = 0;
|
return newintobject(clReadHeader(self->ob_compressorHdl,
|
||||||
value = clGetDefault(self->ob_compressorHdl, param);
|
headerSize, header));
|
||||||
if (error_handler_called)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (param_type_is_float(self->ob_compressorHdl, param) > 0) {
|
|
||||||
fvalue = clRatioToFloat(value);
|
|
||||||
return newfloatobject(fvalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newintobject(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct methodlist compressor_methods[] = {
|
static struct methodlist compressor_methods[] = {
|
||||||
|
@ -559,9 +661,14 @@ static struct methodlist compressor_methods[] = {
|
||||||
{"GetDefault", clm_GetDefault},
|
{"GetDefault", clm_GetDefault},
|
||||||
{"GetMinMax", clm_GetMinMax},
|
{"GetMinMax", clm_GetMinMax},
|
||||||
{"GetName", clm_GetName},
|
{"GetName", clm_GetName},
|
||||||
|
{"GetParam", clm_GetParam},
|
||||||
{"GetParamID", clm_GetParamID},
|
{"GetParamID", clm_GetParamID},
|
||||||
{"GetParams", clm_GetParams},
|
{"GetParams", clm_GetParams},
|
||||||
{"QueryParams", clm_QueryParams},
|
{"QueryParams", clm_QueryParams},
|
||||||
|
{"SetDefault", clm_SetDefault},
|
||||||
|
{"SetMax", clm_SetMax},
|
||||||
|
{"SetMin", clm_SetMin},
|
||||||
|
{"SetParam", clm_SetParam},
|
||||||
{"SetParams", clm_SetParams},
|
{"SetParams", clm_SetParams},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
@ -573,9 +680,15 @@ static struct methodlist decompressor_methods[] = {
|
||||||
{"GetDefault", clm_GetDefault},
|
{"GetDefault", clm_GetDefault},
|
||||||
{"GetMinMax", clm_GetMinMax},
|
{"GetMinMax", clm_GetMinMax},
|
||||||
{"GetName", clm_GetName},
|
{"GetName", clm_GetName},
|
||||||
|
{"GetParam", clm_GetParam},
|
||||||
{"GetParamID", clm_GetParamID},
|
{"GetParamID", clm_GetParamID},
|
||||||
{"GetParams", clm_GetParams},
|
{"GetParams", clm_GetParams},
|
||||||
|
{"ReadHeader", clm_ReadHeader},
|
||||||
{"QueryParams", clm_QueryParams},
|
{"QueryParams", clm_QueryParams},
|
||||||
|
{"SetDefault", clm_SetDefault},
|
||||||
|
{"SetMax", clm_SetMax},
|
||||||
|
{"SetMin", clm_SetMin},
|
||||||
|
{"SetParam", clm_SetParam},
|
||||||
{"SetParams", clm_SetParams},
|
{"SetParams", clm_SetParams},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
@ -625,10 +738,10 @@ static typeobject Cltype = {
|
||||||
static object *
|
static object *
|
||||||
doOpen(self, args, open_func, iscompressor)
|
doOpen(self, args, open_func, iscompressor)
|
||||||
object *self, *args;
|
object *self, *args;
|
||||||
long (*open_func) PROTO((long, CL_Handle *));
|
int (*open_func) PROTO((int, CL_Handle *));
|
||||||
int iscompressor;
|
int iscompressor;
|
||||||
{
|
{
|
||||||
long scheme;
|
int scheme;
|
||||||
clobject *new;
|
clobject *new;
|
||||||
|
|
||||||
if (!getargs(args, "i", &scheme))
|
if (!getargs(args, "i", &scheme))
|
||||||
|
@ -665,11 +778,138 @@ cl_OpenDecompressor(self, args)
|
||||||
return doOpen(self, args, clOpenDecompressor, 0);
|
return doOpen(self, args, clOpenDecompressor, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
cl_QueryScheme(self, args)
|
||||||
|
object *self, *args;
|
||||||
|
{
|
||||||
|
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 *
|
||||||
|
cl_QueryMaxHeaderSize(self, args)
|
||||||
|
object *self, *args;
|
||||||
|
{
|
||||||
|
int scheme;
|
||||||
|
|
||||||
|
if (!getargs(args, "i", &scheme))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return newintobject(clQueryMaxHeaderSize(scheme));
|
||||||
|
}
|
||||||
|
|
||||||
|
static object *
|
||||||
|
cl_QueryAlgorithms(self, args)
|
||||||
|
object *self, *args;
|
||||||
|
{
|
||||||
|
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 *
|
||||||
|
cl_QuerySchemeFromName(self, args)
|
||||||
|
object *self, *args;
|
||||||
|
{
|
||||||
|
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 *
|
||||||
|
cl_GetAlgorithmName(self, args)
|
||||||
|
object *self, *args;
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
static struct methodlist cl_methods[] = {
|
static struct methodlist cl_methods[] = {
|
||||||
{"CompressImage", cl_CompressImage},
|
{"CompressImage", cl_CompressImage},
|
||||||
{"DecompressImage", cl_DecompressImage},
|
{"DecompressImage", cl_DecompressImage},
|
||||||
|
{"GetAlgorithmName", cl_GetAlgorithmName},
|
||||||
{"OpenCompressor", cl_OpenCompressor},
|
{"OpenCompressor", cl_OpenCompressor},
|
||||||
{"OpenDecompressor", cl_OpenDecompressor},
|
{"OpenDecompressor", cl_OpenDecompressor},
|
||||||
|
{"QueryAlgorithms", cl_QueryAlgorithms},
|
||||||
|
{"QueryMaxHeaderSize", cl_QueryMaxHeaderSize},
|
||||||
|
{"QueryScheme", cl_QueryScheme},
|
||||||
|
{"QuerySchemeFromName", cl_QuerySchemeFromName},
|
||||||
{NULL, NULL} /* Sentinel */
|
{NULL, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue