[Python-checkins] python/dist/src/Lib/plat-mac/Carbon MediaDescr.py,1.1,1.2
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Sun, 06 Apr 2003 01:01:35 -0800
- Previous message: [Python-checkins] python/dist/src/Lib/lib-tk Canvas.py,1.18,1.19 Dialog.py,1.5,1.6 ScrolledText.py,1.12,1.13 Tix.py,1.15,1.16 Tkinter.py,1.170,1.171 tkColorChooser.py,1.5,1.6 tkCommonDialog.py,1.6,1.7 tkFont.py,1.3,1.4 tkMessageBox.py,1.1,1.2 tkSimpleDialog.py,1.8,1.9 turtle.py,1.9,1.10
- Next message: [Python-checkins] python/dist/src/Lib/plat-mac EasyDialogs.py,1.11,1.12 FrameWork.py,1.3,1.4 MiniAEFrame.py,1.1,1.2 argvemulator.py,1.2,1.3 icopen.py,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon
In directory sc8-pr-cvs1:/tmp/cvs-serv1577/Lib/plat-mac/Carbon
Modified Files:
MediaDescr.py
Log Message:
SF patch #701494: more apply removals
Index: MediaDescr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/plat-mac/Carbon/MediaDescr.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MediaDescr.py 30 Dec 2002 22:04:21 -0000 1.1
--- MediaDescr.py 6 Apr 2003 09:01:02 -0000 1.2
***************
*** 5,96 ****
class _MediaDescriptionCodec:
! def __init__(self, trunc, size, names, fmt):
! self.trunc = trunc
! self.size = size
! self.names = names
! self.fmt = fmt
!
! def decode(self, data):
! if self.trunc:
! data = data[:self.size]
! values = struct.unpack(self.fmt, data)
! if len(values) != len(self.names):
! raise Error, ('Format length does not match number of names', descr)
! rv = {}
! for i in range(len(values)):
! name = self.names[i]
! value = values[i]
! if type(name) == type(()):
! name, cod, dec = name
! value = dec(value)
! rv[name] = value
! return rv
!
! def encode(dict):
! list = [self.fmt]
! for name in self.names:
! if type(name) == type(()):
! name, cod, dec = name
! else:
! cod = dec = None
! value = dict[name]
! if cod:
! value = cod(value)
! list.append(value)
! rv = apply(struct.pack, tuple(list))
! return rv
!
# Helper functions
def _tofixed(float):
! hi = int(float)
! lo = int(float*0x10000) & 0xffff
! return (hi<<16)|lo
!
def _fromfixed(fixed):
! hi = (fixed >> 16) & 0xffff
! lo = (fixed & 0xffff)
! return hi + (lo / float(0x10000))
!
def _tostr31(str):
! return chr(len(str)) + str + '\0'*(31-len(str))
!
def _fromstr31(str31):
! return str31[1:1+ord(str31[0])]
SampleDescription = _MediaDescriptionCodec(
! 1, # May be longer, truncate
! 16, # size
! ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex'), # Attributes
! "l4slhh" # Format
)
SoundDescription = _MediaDescriptionCodec(
! 1,
! 36,
! ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex',
! 'version', 'revlevel', 'vendor', 'numChannels', 'sampleSize',
! 'compressionID', 'packetSize', ('sampleRate', _tofixed, _fromfixed)),
! "l4slhhhh4shhhhl" # Format
)
SoundDescriptionV1 = _MediaDescriptionCodec(
! 1,
! 52,
! ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex',
! 'version', 'revlevel', 'vendor', 'numChannels', 'sampleSize',
! 'compressionID', 'packetSize', ('sampleRate', _tofixed, _fromfixed), 'samplesPerPacket',
! 'bytesPerPacket', 'bytesPerFrame', 'bytesPerSample'),
! "l4slhhhh4shhhhlllll" # Format
)
ImageDescription = _MediaDescriptionCodec(
! 1, # May be longer, truncate
! 86, # size
! ('idSize', 'cType', 'resvd1', 'resvd2', 'dataRefIndex', 'version',
! 'revisionLevel', 'vendor', 'temporalQuality', 'spatialQuality',
! 'width', 'height', ('hRes', _tofixed, _fromfixed), ('vRes', _tofixed, _fromfixed),
! 'dataSize', 'frameCount', ('name', _tostr31, _fromstr31),
! 'depth', 'clutID'),
! 'l4slhhhh4sllhhlllh32shh',
)
--- 5,96 ----
class _MediaDescriptionCodec:
! def __init__(self, trunc, size, names, fmt):
! self.trunc = trunc
! self.size = size
! self.names = names
! self.fmt = fmt
!
! def decode(self, data):
! if self.trunc:
! data = data[:self.size]
! values = struct.unpack(self.fmt, data)
! if len(values) != len(self.names):
! raise Error, ('Format length does not match number of names', descr)
! rv = {}
! for i in range(len(values)):
! name = self.names[i]
! value = values[i]
! if type(name) == type(()):
! name, cod, dec = name
! value = dec(value)
! rv[name] = value
! return rv
!
! def encode(dict):
! list = [self.fmt]
! for name in self.names:
! if type(name) == type(()):
! name, cod, dec = name
! else:
! cod = dec = None
! value = dict[name]
! if cod:
! value = cod(value)
! list.append(value)
! rv = struct.pack(*list)
! return rv
!
# Helper functions
def _tofixed(float):
! hi = int(float)
! lo = int(float*0x10000) & 0xffff
! return (hi<<16)|lo
!
def _fromfixed(fixed):
! hi = (fixed >> 16) & 0xffff
! lo = (fixed & 0xffff)
! return hi + (lo / float(0x10000))
!
def _tostr31(str):
! return chr(len(str)) + str + '\0'*(31-len(str))
!
def _fromstr31(str31):
! return str31[1:1+ord(str31[0])]
SampleDescription = _MediaDescriptionCodec(
! 1, # May be longer, truncate
! 16, # size
! ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex'), # Attributes
! "l4slhh" # Format
)
SoundDescription = _MediaDescriptionCodec(
! 1,
! 36,
! ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex',
! 'version', 'revlevel', 'vendor', 'numChannels', 'sampleSize',
! 'compressionID', 'packetSize', ('sampleRate', _tofixed, _fromfixed)),
! "l4slhhhh4shhhhl" # Format
)
SoundDescriptionV1 = _MediaDescriptionCodec(
! 1,
! 52,
! ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex',
! 'version', 'revlevel', 'vendor', 'numChannels', 'sampleSize',
! 'compressionID', 'packetSize', ('sampleRate', _tofixed, _fromfixed), 'samplesPerPacket',
! 'bytesPerPacket', 'bytesPerFrame', 'bytesPerSample'),
! "l4slhhhh4shhhhlllll" # Format
)
ImageDescription = _MediaDescriptionCodec(
! 1, # May be longer, truncate
! 86, # size
! ('idSize', 'cType', 'resvd1', 'resvd2', 'dataRefIndex', 'version',
! 'revisionLevel', 'vendor', 'temporalQuality', 'spatialQuality',
! 'width', 'height', ('hRes', _tofixed, _fromfixed), ('vRes', _tofixed, _fromfixed),
! 'dataSize', 'frameCount', ('name', _tostr31, _fromstr31),
! 'depth', 'clutID'),
! 'l4slhhhh4sllhhlllh32shh',
)
- Previous message: [Python-checkins] python/dist/src/Lib/lib-tk Canvas.py,1.18,1.19 Dialog.py,1.5,1.6 ScrolledText.py,1.12,1.13 Tix.py,1.15,1.16 Tkinter.py,1.170,1.171 tkColorChooser.py,1.5,1.6 tkCommonDialog.py,1.6,1.7 tkFont.py,1.3,1.4 tkMessageBox.py,1.1,1.2 tkSimpleDialog.py,1.8,1.9 turtle.py,1.9,1.10
- Next message: [Python-checkins] python/dist/src/Lib/plat-mac EasyDialogs.py,1.11,1.12 FrameWork.py,1.3,1.4 MiniAEFrame.py,1.1,1.2 argvemulator.py,1.2,1.3 icopen.py,1.1,1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]