mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
[Sjoerd Mullender]
Don't use CL module since all constants are now in cl.
This commit is contained in:
parent
1015be3812
commit
2c2f731daf
3 changed files with 64 additions and 65 deletions
49
Lib/aifc.py
49
Lib/aifc.py
|
@ -135,10 +135,6 @@
|
||||||
|
|
||||||
import struct
|
import struct
|
||||||
import __builtin__
|
import __builtin__
|
||||||
try:
|
|
||||||
import CL
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
Error = 'aifc.Error'
|
Error = 'aifc.Error'
|
||||||
|
|
||||||
|
@ -378,13 +374,14 @@ class Aifc_read:
|
||||||
if not self._comm_chunk_read or not self._ssnd_chunk:
|
if not self._comm_chunk_read or not self._ssnd_chunk:
|
||||||
raise Error, 'COMM chunk and/or SSND chunk missing'
|
raise Error, 'COMM chunk and/or SSND chunk missing'
|
||||||
if self._aifc and self._decomp:
|
if self._aifc and self._decomp:
|
||||||
params = [CL.ORIGINAL_FORMAT, 0,
|
import cl
|
||||||
CL.BITS_PER_COMPONENT, self._sampwidth * 8,
|
params = [cl.ORIGINAL_FORMAT, 0,
|
||||||
CL.FRAME_RATE, self._framerate]
|
cl.BITS_PER_COMPONENT, self._sampwidth * 8,
|
||||||
|
cl.FRAME_RATE, self._framerate]
|
||||||
if self._nchannels == 1:
|
if self._nchannels == 1:
|
||||||
params[1] = CL.MONO
|
params[1] = cl.MONO
|
||||||
elif self._nchannels == 2:
|
elif self._nchannels == 2:
|
||||||
params[1] = CL.STEREO_INTERLEAVED
|
params[1] = cl.STEREO_INTERLEAVED
|
||||||
else:
|
else:
|
||||||
raise Error, 'cannot compress more than 2 channels'
|
raise Error, 'cannot compress more than 2 channels'
|
||||||
self._decomp.SetParams(params)
|
self._decomp.SetParams(params)
|
||||||
|
@ -483,7 +480,8 @@ class Aifc_read:
|
||||||
## if 0: access *: private
|
## if 0: access *: private
|
||||||
|
|
||||||
def _decomp_data(self, data):
|
def _decomp_data(self, data):
|
||||||
dummy = self._decomp.SetParam(CL.FRAME_BUFFER_SIZE,
|
import cl
|
||||||
|
dummy = self._decomp.SetParam(cl.FRAME_BUFFER_SIZE,
|
||||||
len(data) * 2)
|
len(data) * 2)
|
||||||
return self._decomp.Decompress(len(data) / self._nchannels,
|
return self._decomp.Decompress(len(data) / self._nchannels,
|
||||||
data)
|
data)
|
||||||
|
@ -537,7 +535,7 @@ class Aifc_read:
|
||||||
return
|
return
|
||||||
# for ULAW and ALAW try Compression Library
|
# for ULAW and ALAW try Compression Library
|
||||||
try:
|
try:
|
||||||
import cl, CL
|
import cl
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if self._comptype == 'ULAW':
|
if self._comptype == 'ULAW':
|
||||||
try:
|
try:
|
||||||
|
@ -549,10 +547,10 @@ class Aifc_read:
|
||||||
pass
|
pass
|
||||||
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
|
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
|
self._framesize = self._framesize / 2
|
||||||
else:
|
else:
|
||||||
raise Error, 'unsupported compression type'
|
raise Error, 'unsupported compression type'
|
||||||
|
@ -810,8 +808,9 @@ class Aifc_write:
|
||||||
## if 0: access *: private
|
## if 0: access *: private
|
||||||
|
|
||||||
def _comp_data(self, data):
|
def _comp_data(self, data):
|
||||||
dum = self._comp.SetParam(CL.FRAME_BUFFER_SIZE, len(data))
|
import cl
|
||||||
dum = self._comp.SetParam(CL.COMPRESSED_BUFFER_SIZE, len(data))
|
dum = self._comp.SetParam(cl.FRAME_BUFFER_SIZE, len(data))
|
||||||
|
dum = self._comp.SetParam(cl.COMPRESSED_BUFFER_SIZE, len(data))
|
||||||
return self._comp.Compress(nframes, data)
|
return self._comp.Compress(nframes, data)
|
||||||
|
|
||||||
def _lin2ulaw(self, data):
|
def _lin2ulaw(self, data):
|
||||||
|
@ -852,7 +851,7 @@ class Aifc_write:
|
||||||
self._convert = self._lin2adpcm
|
self._convert = self._lin2adpcm
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
import cl, CL
|
import cl
|
||||||
except ImportError:
|
except ImportError:
|
||||||
if self._comptype == 'ULAW':
|
if self._comptype == 'ULAW':
|
||||||
try:
|
try:
|
||||||
|
@ -863,21 +862,21 @@ class Aifc_write:
|
||||||
pass
|
pass
|
||||||
raise Error, 'cannot write compressed AIFF-C files'
|
raise Error, 'cannot write compressed AIFF-C files'
|
||||||
if self._comptype == 'ULAW':
|
if self._comptype == 'ULAW':
|
||||||
scheme = CL.G711_ULAW
|
scheme = cl.G711_ULAW
|
||||||
elif self._comptype == 'ALAW':
|
elif self._comptype == 'ALAW':
|
||||||
scheme = CL.G711_ALAW
|
scheme = cl.G711_ALAW
|
||||||
else:
|
else:
|
||||||
raise Error, 'unsupported compression type'
|
raise Error, 'unsupported compression type'
|
||||||
self._comp = cl.OpenCompressor(scheme)
|
self._comp = cl.OpenCompressor(scheme)
|
||||||
params = [CL.ORIGINAL_FORMAT, 0,
|
params = [cl.ORIGINAL_FORMAT, 0,
|
||||||
CL.BITS_PER_COMPONENT, self._sampwidth * 8,
|
cl.BITS_PER_COMPONENT, self._sampwidth * 8,
|
||||||
CL.FRAME_RATE, self._framerate,
|
cl.FRAME_RATE, self._framerate,
|
||||||
CL.FRAME_BUFFER_SIZE, 100,
|
cl.FRAME_BUFFER_SIZE, 100,
|
||||||
CL.COMPRESSED_BUFFER_SIZE, 100]
|
cl.COMPRESSED_BUFFER_SIZE, 100]
|
||||||
if self._nchannels == 1:
|
if self._nchannels == 1:
|
||||||
params[1] = CL.MONO
|
params[1] = cl.MONO
|
||||||
elif self._nchannels == 2:
|
elif self._nchannels == 2:
|
||||||
params[1] = CL.STEREO_INTERLEAVED
|
params[1] = cl.STEREO_INTERLEAVED
|
||||||
else:
|
else:
|
||||||
raise Error, 'cannot compress more than 2 channels'
|
raise Error, 'cannot compress more than 2 channels'
|
||||||
self._comp.SetParams(params)
|
self._comp.SetParams(params)
|
||||||
|
|
|
@ -14,22 +14,22 @@ decomp = None
|
||||||
|
|
||||||
def compress(imgdata, width, height, bytesperpixel):
|
def compress(imgdata, width, height, bytesperpixel):
|
||||||
global comp
|
global comp
|
||||||
import cl, CL
|
import cl
|
||||||
if comp is None: comp = cl.OpenCompressor(CL.JPEG)
|
if comp is None: comp = cl.OpenCompressor(cl.JPEG)
|
||||||
if bytesperpixel == 1:
|
if bytesperpixel == 1:
|
||||||
format = CL.GRAYSCALE
|
format = cl.GRAYSCALE
|
||||||
elif bytesperpixel == 4:
|
elif bytesperpixel == 4:
|
||||||
format = CL.RGBX
|
format = cl.RGBX
|
||||||
if options['forcegray']:
|
if options['forcegray']:
|
||||||
iformat = CL.GRAYSCALE
|
iformat = cl.GRAYSCALE
|
||||||
else:
|
else:
|
||||||
iformat = CL.YUV
|
iformat = cl.YUV
|
||||||
# XXX How to support 'optimize'?
|
# XXX How to support 'optimize'?
|
||||||
params = [CL.IMAGE_WIDTH, width, CL.IMAGE_HEIGHT, height, \
|
params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, \
|
||||||
CL.ORIGINAL_FORMAT, format, \
|
cl.ORIGINAL_FORMAT, format, \
|
||||||
CL.ORIENTATION, CL.BOTTOM_UP, \
|
cl.ORIENTATION, cl.BOTTOM_UP, \
|
||||||
CL.QUALITY_FACTOR, options['quality'], \
|
cl.QUALITY_FACTOR, options['quality'], \
|
||||||
CL.INTERNAL_FORMAT, iformat, \
|
cl.INTERNAL_FORMAT, iformat, \
|
||||||
]
|
]
|
||||||
comp.SetParams(params)
|
comp.SetParams(params)
|
||||||
jpegdata = comp.Compress(1, imgdata)
|
jpegdata = comp.Compress(1, imgdata)
|
||||||
|
@ -37,22 +37,22 @@ def compress(imgdata, width, height, bytesperpixel):
|
||||||
|
|
||||||
def decompress(jpegdata):
|
def decompress(jpegdata):
|
||||||
global decomp
|
global decomp
|
||||||
import cl, CL
|
import cl
|
||||||
if decomp is None: decomp = cl.OpenDecompressor(CL.JPEG)
|
if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
|
||||||
headersize = decomp.ReadHeader(jpegdata)
|
headersize = decomp.ReadHeader(jpegdata)
|
||||||
params = [CL.IMAGE_WIDTH, 0, CL.IMAGE_HEIGHT, 0, CL.INTERNAL_FORMAT, 0]
|
params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
|
||||||
decomp.GetParams(params)
|
decomp.GetParams(params)
|
||||||
width, height, format = params[1], params[3], params[5]
|
width, height, format = params[1], params[3], params[5]
|
||||||
if format == CL.GRAYSCALE or options['forcegray']:
|
if format == cl.GRAYSCALE or options['forcegray']:
|
||||||
format = CL.GRAYSCALE
|
format = cl.GRAYSCALE
|
||||||
bytesperpixel = 1
|
bytesperpixel = 1
|
||||||
else:
|
else:
|
||||||
format = CL.RGBX
|
format = cl.RGBX
|
||||||
bytesperpixel = 4
|
bytesperpixel = 4
|
||||||
# XXX How to support 'smooth'?
|
# XXX How to support 'smooth'?
|
||||||
params = [CL.ORIGINAL_FORMAT, format, \
|
params = [cl.ORIGINAL_FORMAT, format, \
|
||||||
CL.ORIENTATION, CL.BOTTOM_UP, \
|
cl.ORIENTATION, cl.BOTTOM_UP, \
|
||||||
CL.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
|
cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
|
||||||
decomp.SetParams(params)
|
decomp.SetParams(params)
|
||||||
imgdata = decomp.Decompress(1, jpegdata)
|
imgdata = decomp.Decompress(1, jpegdata)
|
||||||
return imgdata, width, height, bytesperpixel
|
return imgdata, width, height, bytesperpixel
|
||||||
|
|
|
@ -14,22 +14,22 @@ decomp = None
|
||||||
|
|
||||||
def compress(imgdata, width, height, bytesperpixel):
|
def compress(imgdata, width, height, bytesperpixel):
|
||||||
global comp
|
global comp
|
||||||
import cl, CL
|
import cl
|
||||||
if comp is None: comp = cl.OpenCompressor(CL.JPEG)
|
if comp is None: comp = cl.OpenCompressor(cl.JPEG)
|
||||||
if bytesperpixel == 1:
|
if bytesperpixel == 1:
|
||||||
format = CL.GRAYSCALE
|
format = cl.GRAYSCALE
|
||||||
elif bytesperpixel == 4:
|
elif bytesperpixel == 4:
|
||||||
format = CL.RGBX
|
format = cl.RGBX
|
||||||
if options['forcegray']:
|
if options['forcegray']:
|
||||||
iformat = CL.GRAYSCALE
|
iformat = cl.GRAYSCALE
|
||||||
else:
|
else:
|
||||||
iformat = CL.YUV
|
iformat = cl.YUV
|
||||||
# XXX How to support 'optimize'?
|
# XXX How to support 'optimize'?
|
||||||
params = [CL.IMAGE_WIDTH, width, CL.IMAGE_HEIGHT, height, \
|
params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height,
|
||||||
CL.ORIGINAL_FORMAT, format, \
|
cl.ORIGINAL_FORMAT, format,
|
||||||
CL.ORIENTATION, CL.BOTTOM_UP, \
|
cl.ORIENTATION, cl.BOTTOM_UP,
|
||||||
CL.QUALITY_FACTOR, options['quality'], \
|
cl.QUALITY_FACTOR, options['quality'],
|
||||||
CL.INTERNAL_FORMAT, iformat, \
|
cl.INTERNAL_FORMAT, iformat,
|
||||||
]
|
]
|
||||||
comp.SetParams(params)
|
comp.SetParams(params)
|
||||||
jpegdata = comp.Compress(1, imgdata)
|
jpegdata = comp.Compress(1, imgdata)
|
||||||
|
@ -37,22 +37,22 @@ def compress(imgdata, width, height, bytesperpixel):
|
||||||
|
|
||||||
def decompress(jpegdata):
|
def decompress(jpegdata):
|
||||||
global decomp
|
global decomp
|
||||||
import cl, CL
|
import cl
|
||||||
if decomp is None: decomp = cl.OpenDecompressor(CL.JPEG)
|
if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
|
||||||
headersize = decomp.ReadHeader(jpegdata)
|
headersize = decomp.ReadHeader(jpegdata)
|
||||||
params = [CL.IMAGE_WIDTH, 0, CL.IMAGE_HEIGHT, 0, CL.INTERNAL_FORMAT, 0]
|
params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
|
||||||
decomp.GetParams(params)
|
decomp.GetParams(params)
|
||||||
width, height, format = params[1], params[3], params[5]
|
width, height, format = params[1], params[3], params[5]
|
||||||
if format == CL.GRAYSCALE or options['forcegray']:
|
if format == cl.GRAYSCALE or options['forcegray']:
|
||||||
format = CL.GRAYSCALE
|
format = cl.GRAYSCALE
|
||||||
bytesperpixel = 1
|
bytesperpixel = 1
|
||||||
else:
|
else:
|
||||||
format = CL.RGBX
|
format = cl.RGBX
|
||||||
bytesperpixel = 4
|
bytesperpixel = 4
|
||||||
# XXX How to support 'smooth'?
|
# XXX How to support 'smooth'?
|
||||||
params = [CL.ORIGINAL_FORMAT, format, \
|
params = [cl.ORIGINAL_FORMAT, format,
|
||||||
CL.ORIENTATION, CL.BOTTOM_UP, \
|
cl.ORIENTATION, cl.BOTTOM_UP,
|
||||||
CL.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
|
cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
|
||||||
decomp.SetParams(params)
|
decomp.SetParams(params)
|
||||||
imgdata = decomp.Decompress(1, jpegdata)
|
imgdata = decomp.Decompress(1, jpegdata)
|
||||||
return imgdata, width, height, bytesperpixel
|
return imgdata, width, height, bytesperpixel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue