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 # 11 from warnings import warnpy3k 12 warnpy3k("the CL_old module has been removed in Python 3.0", stacklevel=2) 13 del warnpy3k 14 15 MAX_NUMBER_OF_ORIGINAL_FORMATS = 32 16 17 # Audio 18 MONO = 0 19 STEREO_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 # 29 RGB = 0 30 RGBX = 1 31 RGBA = 2 32 RGB332 = 3 33 34 GRAYSCALE = 4 35 Y = 4 36 YUV = 5 37 YCbCr = 5 38 YUV422 = 6 # 4:2:2 sampling 39 YCbCr422 = 6 # 4:2:2 sampling 40 YUV422HC = 7 # 4:1:1 sampling 41 YCbCr422HC = 7 # 4:1:1 sampling 42 YUV422DC = 7 # 4:1:1 sampling 43 YCbCr422DC = 7 # 4:1:1 sampling 44 45 BEST_FIT = -1 46 47 def 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 55 def 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 65 def 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 73 def 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 93 MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32 94 MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32 95 96 # 97 # Algorithm types 98 # 99 AUDIO = 0 100 VIDEO = 1 101 102 def AlgorithmNumber(scheme): 103 return scheme & 0x7fff 104 def AlgorithmType(scheme): 105 return (scheme >> 15) & 1 106 def Algorithm(type, n): 107 return n | ((type & 1) << 15) 108 109 # 110 # "compressionScheme" argument values 111 # 112 UNKNOWN_SCHEME = -1 113 114 UNCOMPRESSED_AUDIO = Algorithm(AUDIO, 0) 115 G711_ULAW = Algorithm(AUDIO, 1) 116 ULAW = Algorithm(AUDIO, 1) 117 G711_ALAW = Algorithm(AUDIO, 2) 118 ALAW = Algorithm(AUDIO, 2) 119 AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3) 120 AWARE_MULTIRATE = Algorithm(AUDIO, 4) 121 122 UNCOMPRESSED = Algorithm(VIDEO, 0) 123 UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0) 124 RLE = Algorithm(VIDEO, 1) 125 JPEG = Algorithm(VIDEO, 2) 126 MPEG_VIDEO = Algorithm(VIDEO, 3) 127 MVC1 = Algorithm(VIDEO, 4) 128 RTR = Algorithm(VIDEO, 5) 129 RTR1 = Algorithm(VIDEO, 5) 130 131 # 132 # Parameters 133 # 134 MAX_NUMBER_OF_PARAMS = 256 135 # Default Parameters 136 IMAGE_WIDTH = 0 137 IMAGE_HEIGHT = 1 138 ORIGINAL_FORMAT = 2 139 INTERNAL_FORMAT = 3 140 COMPONENTS = 4 141 BITS_PER_COMPONENT = 5 142 FRAME_RATE = 6 143 COMPRESSION_RATIO = 7 144 EXACT_COMPRESSION_RATIO = 8 145 FRAME_BUFFER_SIZE = 9 146 COMPRESSED_BUFFER_SIZE = 10 147 BLOCK_SIZE = 11 148 PREROLL = 12 149 FRAME_TYPE = 13 150 ALGORITHM_ID = 14 151 ALGORITHM_VERSION = 15 152 ORIENTATION = 16 153 NUMBER_OF_FRAMES = 17 154 SPEED = 18 155 LAST_FRAME_INDEX = 19 156 NUMBER_OF_PARAMS = 20 157 158 # JPEG Specific Parameters 159 QUALITY_FACTOR = NUMBER_OF_PARAMS + 0 160 161 # MPEG Specific Parameters 162 END_OF_SEQUENCE = NUMBER_OF_PARAMS + 0 163 164 # RTR Specific Parameters 165 QUALITY_LEVEL = NUMBER_OF_PARAMS + 0 166 ZOOM_X = NUMBER_OF_PARAMS + 1 167 ZOOM_Y = NUMBER_OF_PARAMS + 2 168 169 # 170 # Parameter value types 171 # 172 ENUM_VALUE = 0 # only certain constant values are valid 173 RANGE_VALUE = 1 # any value in a given range is valid 174 FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid 175 FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid 176 177 # 178 # Algorithm Functionality 179 # 180 DECOMPRESSOR = 1 181 COMPRESSOR = 2 182 CODEC = 3 183 184 # 185 # Buffer types 186 # 187 NONE = 0 188 FRAME = 1 189 DATA = 2 190 191 # 192 # Frame types 193 # 194 NONE = 0 195 KEYFRAME = 1 196 INTRA = 1 197 PREDICTED = 2 198 BIDIRECTIONAL = 3 199 200 # 201 # Orientations 202 # 203 TOP_DOWN = 0 204 BOTTOM_UP = 1 205 206 # 207 # SGI Proprietary Algorithm Header Start Code 208 # 209 HEADER_START_CODE = 0xc1C0DEC 210 211 # 212 # error codes 213 # 214 215 BAD_NO_BUFFERSPACE = -2 # no space for internal buffers 216 BAD_PVBUFFER = -3 # param/val buffer doesn't make sense 217 BAD_BUFFERLENGTH_NEG = -4 # negative buffer length 218 BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer 219 BAD_PARAM = -6 # invalid parameter 220 BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid 221 BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid 222 BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid 223 BAD_BUFFER_HANDLE = -10 # buffer handle invalid 224 BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large 225 JPEG_ERROR = -12 # error from libjpeg 226 BAD_FRAME_SIZE = -13 # frame size invalid 227 PARAM_OUT_OF_RANGE = -14 # parameter out of range 228 ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error 229 BAD_ALGORITHM_TYPE = -16 # bad algorithm type 230 BAD_ALGORITHM_NAME = -17 # bad algorithm name 231 BAD_BUFFERING = -18 # bad buffering calls 232 BUFFER_NOT_CREATED = -19 # buffer not created 233 BAD_BUFFER_EXISTS = -20 # buffer already created 234 BAD_INTERNAL_FORMAT = -21 # invalid internal format 235 BAD_BUFFER_POINTER = -22 # invalid buffer pointer 236 FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size 237 BAD_STREAM_HEADER = -24 # invalid stream header 238 239 BAD_LICENSE = -25 # netls license not valid 240 AWARE_ERROR = -26 # error from libawcmp 241