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