• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# cl.h - Compression Library typedefs and prototypes
3#
4#   01/07/92    Cleanup by Brian Knittel
5#   02/18/92    Original Version by Brian Knittel
6#
7
8#
9# originalFormat parameter values
10#
11from warnings import warnpy3k
12warnpy3k("the CL_old module has been removed in Python 3.0", stacklevel=2)
13del warnpy3k
14
15MAX_NUMBER_OF_ORIGINAL_FORMATS = 32
16
17# Audio
18MONO = 0
19STEREO_INTERLEAVED = 1
20
21# Video
22# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
23# 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
24#       horizontally, packed as U Y1 V Y2 (byte order).
25# 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
26#       vertically in addition to horizontally, and is packed the same as
27#       422 except that U & V are not valid on the second line.
28#
29RGB = 0
30RGBX = 1
31RGBA = 2
32RGB332 = 3
33
34GRAYSCALE = 4
35Y = 4
36YUV = 5
37YCbCr = 5
38YUV422 = 6                              # 4:2:2 sampling
39YCbCr422 = 6                            # 4:2:2 sampling
40YUV422HC = 7                            # 4:1:1 sampling
41YCbCr422HC = 7                          # 4:1:1 sampling
42YUV422DC = 7                            # 4:1:1 sampling
43YCbCr422DC = 7                          # 4:1:1 sampling
44
45BEST_FIT = -1
46
47def BytesPerSample(s):
48    if s in (MONO, YUV):
49        return 2
50    elif s == STEREO_INTERLEAVED:
51        return 4
52    else:
53        return 0
54
55def BytesPerPixel(f):
56    if f in (RGB, YUV):
57        return 3
58    elif f in (RGBX, RGBA):
59        return 4
60    elif f in (RGB332, GRAYSCALE):
61        return 1
62    else:
63        return 2
64
65def AudioFormatName(f):
66    if f == MONO:
67        return 'MONO'
68    elif f == STEREO_INTERLEAVED:
69        return 'STEREO_INTERLEAVED'
70    else:
71        return 'Not a valid format'
72
73def VideoFormatName(f):
74    if f == RGB:
75        return 'RGB'
76    elif f == RGBX:
77        return 'RGBX'
78    elif f == RGBA:
79        return 'RGBA'
80    elif f == RGB332:
81        return 'RGB332'
82    elif f == GRAYSCALE:
83        return 'GRAYSCALE'
84    elif f == YUV:
85        return 'YUV'
86    elif f == YUV422:
87        return 'YUV422'
88    elif f == YUV422DC:
89        return 'YUV422DC'
90    else:
91        return 'Not a valid format'
92
93MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32
94MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32
95
96#
97# Algorithm types
98#
99AUDIO = 0
100VIDEO = 1
101
102def AlgorithmNumber(scheme):
103    return scheme & 0x7fff
104def AlgorithmType(scheme):
105    return (scheme >> 15) & 1
106def Algorithm(type, n):
107    return n | ((type & 1) << 15)
108
109#
110# "compressionScheme" argument values
111#
112UNKNOWN_SCHEME = -1
113
114UNCOMPRESSED_AUDIO = Algorithm(AUDIO, 0)
115G711_ULAW = Algorithm(AUDIO, 1)
116ULAW = Algorithm(AUDIO, 1)
117G711_ALAW = Algorithm(AUDIO, 2)
118ALAW = Algorithm(AUDIO, 2)
119AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3)
120AWARE_MULTIRATE = Algorithm(AUDIO, 4)
121
122UNCOMPRESSED = Algorithm(VIDEO, 0)
123UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0)
124RLE = Algorithm(VIDEO, 1)
125JPEG = Algorithm(VIDEO, 2)
126MPEG_VIDEO = Algorithm(VIDEO, 3)
127MVC1 = Algorithm(VIDEO, 4)
128RTR = Algorithm(VIDEO, 5)
129RTR1 = Algorithm(VIDEO, 5)
130
131#
132# Parameters
133#
134MAX_NUMBER_OF_PARAMS = 256
135# Default Parameters
136IMAGE_WIDTH = 0
137IMAGE_HEIGHT = 1
138ORIGINAL_FORMAT = 2
139INTERNAL_FORMAT = 3
140COMPONENTS = 4
141BITS_PER_COMPONENT = 5
142FRAME_RATE = 6
143COMPRESSION_RATIO = 7
144EXACT_COMPRESSION_RATIO = 8
145FRAME_BUFFER_SIZE = 9
146COMPRESSED_BUFFER_SIZE = 10
147BLOCK_SIZE = 11
148PREROLL = 12
149FRAME_TYPE = 13
150ALGORITHM_ID = 14
151ALGORITHM_VERSION = 15
152ORIENTATION = 16
153NUMBER_OF_FRAMES = 17
154SPEED = 18
155LAST_FRAME_INDEX = 19
156NUMBER_OF_PARAMS = 20
157
158# JPEG Specific Parameters
159QUALITY_FACTOR = NUMBER_OF_PARAMS + 0
160
161# MPEG Specific Parameters
162END_OF_SEQUENCE = NUMBER_OF_PARAMS + 0
163
164# RTR Specific Parameters
165QUALITY_LEVEL = NUMBER_OF_PARAMS + 0
166ZOOM_X = NUMBER_OF_PARAMS + 1
167ZOOM_Y = NUMBER_OF_PARAMS + 2
168
169#
170# Parameter value types
171#
172ENUM_VALUE = 0                          # only certain constant values are valid
173RANGE_VALUE = 1                         # any value in a given range is valid
174FLOATING_ENUM_VALUE = 2                 # only certain constant floating point values are valid
175FLOATING_RANGE_VALUE = 3                # any value in a given floating point range is valid
176
177#
178# Algorithm Functionality
179#
180DECOMPRESSOR = 1
181COMPRESSOR = 2
182CODEC = 3
183
184#
185# Buffer types
186#
187NONE = 0
188FRAME = 1
189DATA = 2
190
191#
192# Frame types
193#
194NONE = 0
195KEYFRAME = 1
196INTRA = 1
197PREDICTED = 2
198BIDIRECTIONAL = 3
199
200#
201# Orientations
202#
203TOP_DOWN = 0
204BOTTOM_UP = 1
205
206#
207# SGI Proprietary Algorithm Header Start Code
208#
209HEADER_START_CODE = 0xc1C0DEC
210
211#
212# error codes
213#
214
215BAD_NO_BUFFERSPACE =  -2                # no space for internal buffers
216BAD_PVBUFFER =  -3                      # param/val buffer doesn't make sense
217BAD_BUFFERLENGTH_NEG =  -4              # negative buffer length
218BAD_BUFFERLENGTH_ODD =  -5              # odd length parameter/value buffer
219BAD_PARAM =  -6                         # invalid parameter
220BAD_COMPRESSION_SCHEME =  -7            # compression scheme parameter invalid
221BAD_COMPRESSOR_HANDLE =  -8             # compression handle parameter invalid
222BAD_COMPRESSOR_HANDLE_POINTER = -9      # compression handle pointer invalid
223BAD_BUFFER_HANDLE = -10                 # buffer handle invalid
224BAD_BUFFER_QUERY_SIZE = -11             # buffer query size too large
225JPEG_ERROR = -12                        # error from libjpeg
226BAD_FRAME_SIZE = -13                    # frame size invalid
227PARAM_OUT_OF_RANGE = -14                # parameter out of range
228ADDED_ALGORITHM_ERROR = -15             # added algorithm had a unique error
229BAD_ALGORITHM_TYPE = -16                # bad algorithm type
230BAD_ALGORITHM_NAME = -17                # bad algorithm name
231BAD_BUFFERING = -18                     # bad buffering calls
232BUFFER_NOT_CREATED = -19                # buffer not created
233BAD_BUFFER_EXISTS = -20                 # buffer already created
234BAD_INTERNAL_FORMAT = -21               # invalid internal format
235BAD_BUFFER_POINTER = -22                # invalid buffer pointer
236FRAME_BUFFER_SIZE_ZERO = -23            # frame buffer has zero size
237BAD_STREAM_HEADER = -24                 # invalid stream header
238
239BAD_LICENSE = -25                       # netls license not valid
240AWARE_ERROR = -26                       # error from libawcmp
241