1XXX - Not complete. 2 3Name 4 5 SGIX_image_compression 6 7Name Strings 8 9 GL_SGIX_image_compression 10 11Version 12 13 $Date: 1997/06/05 16:11:49 $ $Revision: 1.5 $ 14 15Number 16 17 ??? 18 19Dependencies 20 21 None. 22 23Overview 24 25 This extension defines new pixel storage modes which are used in the 26 conversion of image data to and from compressed formats on the client 27 side. These new compression and decompression operations take place 28 during the pixel packing and unpacking stages of the OpenGL pipeline, 29 respectively, and obey the same semantics as other packing and 30 unpacking modes. This extension defines a framework in which further 31 extensions can provide support for specific compressed formats, and 32 also provides additional infrastructure which is common to various 33 compression techniques, without defining any specific compression 34 formats. Other extensions will define compression formats which make 35 use of this framework. A new pixel unpacking mode and a new pixel 36 packing mode are defined which specify the compressed format of pixel 37 data on the client side. The only legal value this extension defines 38 for these storage modes is NONE; further compression extensions will 39 define additional legal values. 40 41 Many compression techniques utilize various component subsamplings, so 42 it is necessary to provide a mechanism to specify the up- and 43 down-sampling of components as pixel data is decompressed from- and 44 compressed to the client. This extension defines a new pixel storage 45 mode to specify these sampling patterns, and four legal values. When 46 pixel data is decompressed from the client and an unpacking upsampling 47 mode other than SAMPLE_444_SGIX is specified, the upsampling is 48 performed via simple component replication. This preserves all 49 information in the incoming image data, so that if an application 50 requires other types of filtering, they may be performed after 51 decompression. Similarly, when pixel data is compressed to the client 52 and a packing downsampling mode other than SAMPLE_444_SGIX is 53 specified, the downsampling is performed via simple component 54 decimation. If an application requires other types of filtering, they 55 must be performed before compression. 56 57 Some compression formats specify a color space in which the pixels are 58 expressed before compression and after decompression. To make support 59 of these formats more transparent, this extension adds a conversion 60 between the natural color space of the compression format and RGB. 61 This conversion can be enabled separately for packing and for unpacking 62 of pixel data. When it is enabled for unpacking, the pixel data will 63 be converted to RGB after decompression. When it is enabled for 64 packing, the pixel data will be assumed to be represented as RGB, and 65 converted as necessary before compression. The client may wish to 66 disable these automatic conversion in order to apply filtering before 67 the color space conversion in the case of decompression, or after the 68 color space conversion in the case of compression. When the 69 conversions are disabled, the client is responsible for performing the 70 appropriate color space conversions. The alternate color spaces must 71 be defined by the additional compression format extensions. If a new 72 format extension does not specify a preferred color space, this color 73 space conversion has no effect. 74 75Issues 76 77 - Should this be split into multiple extensions? 78 79 - How should bitrate/quality be controlled for vbr techniques? 80 81 - Instead of requiring each compression format extension to specify 82 its own color space, this could be specified by the client using the 83 <format> parameter. This would require the creation of additional 84 formats, but would also have the advantage of more accurately 85 reflecting the format of pixel data, i.e., calling the format of DVC 86 compressed data YCrCb rather than RGB. 87 88 - Should some additional support for up- and down-sampling methods 89 other than replication and decimation be provided? 90 91 - Should we define an error for a bogus compressed frame? 92 Something like COMPRESSION_DATA_ERROR? 93 94 - We define all compression standards as operating on RGBA 95 floating-point images. Is this the correct decision? 96 97 - We ignore color-index images. Is this the correct decision? 98 99 - The current scheme for subrectangle modes doesn't permit the 100 old trick of drawing fields by setting ROW_LENGTH to twice 101 the actual width of the image. Probably the easiest way to 102 fix this would be to add some new pixel storage parameter 103 (FIELD_EXTRACT or something) which would be treated as 104 though it were part of ROW_LENGTH in the non-compressed 105 unpack case. The non-compressed unpack case is a little 106 harder -- it can be done by setting ROW_LEGNTH to one half 107 the width, but bytes past the end of the last scan line are 108 written. 109 110 - What about three- and four-dimensional images? 111 112 - What about three- and four-dimensional subrectangle modes? 113 114New Procedures and Functions 115 116 None. 117 118New Tokens 119 120 Accepted by the <pname> parameter of PixelStoref, PixelStorei, 121 GetBooleanv, GetIntegerv, GetFloatv and GetDoublev: 122 123 PACK_COMPRESSION_TYPE_SGIX 124 UNPACK_COMPRESSION_TYPE_SGIX 125 UNPACK_COMPRESSED_SIZE_SGIX 126 PACK_MAX_COMPRESSED_SIZE_SGIX 127 PACK_SAMPLE_SGIX 128 UNPACK_SAMPLE_SGIX 129 130 Accepted by the <pname> parameter of GetBooleanv, GetIntegerv, 131 GetFloatv and GetDoublev: 132 133 PACK_COMPRESSED_SIZE_SGIX 134 135 Accepted by the <param> parameter of PixelStoref and PixelStorei 136 when the <pname> parameter is PACK_SAMPLE_SGIX or 137 UNPACK_SAMPLE_SGIX: 138 139 SAMPLE_444_SGIX 140 SAMPLE_422_SGIX 141 SAMPLE_411_SGIX 142 SAMPLE_420_SGIX 143 144 Accepted by the <pname> parameter of PixelStoref and 145 PixelStorei with a <param> parameter of TRUE or FALSE and by 146 the <pname> parameter of GetBooleanv, GetIntegerv, GetFloatv 147 and GetDoublev: 148 149 PACK_FROM_RGB_SGIX 150 UNPACK_TO_RGB_SGIX 151 152Additions to Chapter 2 of the 1.0 Specification (OpenGL Operation) 153 154 None. 155 156Additions to Chapter 3 of the 1.0 Specification (Rasterization) 157 158 3.6.1 Pixel Storage Modes 159 160 The following is added to Table 3.1: 161 162 Parameter Name Type Initial Value Valid Range 163 -------------- ---- ------------- ----------- 164 UNPACK_COMPRESSION_TYPE_SGIX integer NONE NONE 165 UNPACK_COMPRESSED_SIZE_SGIX integer 0 [0,inf) 166 UNPACK_SAMPLE_SGIX integer SAMPLE_444_SGIX SAMPLE_444_SGIX, SAMPLE_422_SGIX, SAMPLE_411_SGIX, SAMPLE_420_SGIX 167 UNPACK_TO_RGB_SGIX boolean TRUE TRUE/FALSE 168 169 3.6.3 Rasterization of Pixel Rectangles 170 171 The following is added to the introduction to section 3.6.3: 172 "Unpacking" refers to the reading of pixels from host memory. 173 Pixels are unpacked from host memory as either compressed or 174 uncompressed images. If PACK_COMPRESSION_TYPE_SGIX is set to 175 NONE, the images are stored as uncompressed data and are 176 unpacked from host memory as described below. If 177 PACK_COMPRESSION_TYPE_SGIX is set to a value other than NONE, 178 the images are compressed and are unpacked from host memory as 179 described in "Unpacking of Compressed Images". 180 181 The title of the "Unpacking" subsection is changed to 182 "Unpacking of Uncompressed Images." All references to this 183 subsection are changed as well. 184 185 A new subsection, "Unpacking of Compressed Images," is added 186 between "Unpacking of Uncompressed Images" and the "Conversion 187 to Floating-Point." The contents of the section are as 188 follows: 189 190 In this section, we describe the unpacking of compressed 191 images. The first part describes how images are taken from 192 host memory as a byte stream. Next, a description GL's 193 upsampling algorithms is provided since they are used by 194 several compressed formats. After the upsampling description, 195 paragraphs added by other extensions describe the conversion 196 applied to the byte stream for a given 197 UNPACK_COMPRESSION_TYPE_SGIX. After these descriptions, we 198 describe the application of subrectangle pixel storage modes. 199 200 GL supports four types of upsampling: SAMPLE_444_SGIX, 201 SAMPLE_422_SGIX, SAMPLE_411_SGIX, and SAMPLE_420_SGIX. The 202 type of upsampling performed is determined by the setting of 203 the UNPACK_SAMPLE_SGIX pixel storage parameter. 204 XXX say how the upsampling is performed for each of the 205 things. 206 207 Compressed images are taken from memory as an uninterrupted 208 sequence of bytes beginning at <data> whose length is given by 209 UNPACK_COMPRESSED_SIZE_SGIX. The byte stream is passed to the 210 GL and interpreted as determined by the compression type given 211 by UNPACK_COMPRESSION_TYPE_SGIX. The dimensions of the image 212 represented by the byte stream are determined as follows. The 213 width of the image is equal to the value of UNPACK_ROW_LENGTH 214 if this value is positive, or to <width> otherwise. The 215 height of the image is equal to the value of IMAGE_HEIGHT_EXT 216 if this value is positive, or to <height> otherwise. The 217 width and height refer to the the size of the image after 218 upsampling (see below). 219 220 The pixel storage parameters UNPACK_SWAP_BYTES, 221 UNPACK_LSB_FIRST, and UNPACK_ALIGNMENT are ignored for 222 compressed images. Subrectangle storage modes 223 (UNPACK_SKIP_ROWS, UNPACK_SKIP_PIXELS) are not applied as the 224 image is extracted from memory, but instead are applied after 225 the image has been decompressed. This operation is described 226 in detail at the end of this section. 227 228 Once the byte stream has been taken from host memory, it is 229 decompressed as determined by the setting of 230 UNPACK_COMPRESSION_TYPE_SGIX. The operations are described in 231 detail below. 232 233 The output of the decompression algorithm is a width by height 234 image. A subrectangle of the image may be extracted as 235 determined by the pixel storage parameters UNPACK_SKIP_PIXELS, 236 UNPACK_SKIP_ROWS and by the <width> and <height> arguments to 237 the original entry point (see figure 3.8. The result of 238 application of the subrect algorithm is a <width> by <height> 239 image. 240 241 To compute the subrectangle image, we consider the output of 242 the decompression algorithm as a two-dimensional array of 243 pixels Pin[0...(width-1)][0...(height-1)]. The first index 244 selects the column of the image, the second selects the row. 245 We consider the output of the subrectangle algorithm as a 246 two-dimensional array of pixels 247 Pout[0...(<width>-1)][0...(<height>-1)]. Each pixel the 248 output image is defined by: 249 250 Pout[i][j] = Pin[UNPACK_SKIP_PIXELS + i][UNPACK_SKIP_ROWS + j] 251 252 In this equation, we define the "=" operation to set each 253 channel of the output pixel equal to the equivalent channel of 254 the input pixel. If any of the output pixels are generated 255 from pixels outside of the input image, the values of the 256 components of these pixels are undefined. 257 258Additions to Chapter 4 of the 1.0 Specification (Per-Fragment Operations 259and the Frame Buffer) 260 261 4.3.2 Reading Pixels 262 263 The following entries are added to Table 4.5: 264 265 Parameter Name Type Initial Value Valid Range 266 -------------- ---- ------------- ----------- 267 PACK_COMPRESSION_TYPE_SGIX integer NONE NONE 268 PACK_MAX_COMPRESSED_SIZE_SGIX integer 0 [0,inf) 269 PACK_SAMPLE_SGIX integer SAMPLE_444_SGIX SAMPLE_444_SGIX, SAMPLE_422_SGIX, SAMPLE_411_SGIX, SAMPLE_420_SGIX 270 PACK_FROM_RGB_SGIX boolean TRUE TRUE/FALSE 271 272 The following needs to be added to the end of the "Final 273 Conversion" subsection: If image compression is on 274 (PACK_COMPRESSION_TYPE_SGIX is set to other than NONE), no 275 conversion is applied. 276 277 The subsection titled "Placement in Client Memory" is renamed 278 "Packing of Uncompressed Images." The following is added to 279 the start of the subsection: If image compression is not on 280 (PACK_COMPRESSION_TYPE_SGIX is set to NONE), the pixels of the 281 image are transferred to host memory as described in this 282 section. If compression is on, the pixels are transferred as 283 described in "Packing of Compressed Images." 284 285 A new subsection, "Packing of Compressed Images," is added 286 after the subsection "Packing of Uncompressed Images." The 287 contents of the subsection are as follows: 288 289 If image compression is on (PACK_COMPRESSION_TYPE_SGIX is set 290 to something other than NONE), images are placed in memory as 291 described in this section. The floating-point image from the 292 final conversion step is used as the input to the compression 293 step. The algorithm used for the compression step is 294 determined by the value of PACK_COMPRESSION_TYPE_SGIX. 295 Algorithms are described in separate extensions. The size of 296 the image returned to the host is <width> by <height>. The 297 pixel pack parameters PACK_SWAP_BYTES, PACK_LSB_FIRST, 298 PACK_ROW_LENGTH, PACK_SKIP_ROWS, PACK_SKIP_PIXELS, and 299 PACK_ALIGNMENT are not considered when reading back compressed 300 images. 301 302 The output of the compression step is a byte stream. The 303 compression algorithm sets the value of 304 PACK_COMPRESSED_SIZE_SGIX to the length of the byte stream. 305 The bytes are placed in an uninterrupted stream starting at 306 the location <data> in host memory. If the value of 307 PACK_MAX_COMPRESSED_SIZE_SGIX is greater than zero and the 308 value of PACK_COMPRESSED_SIZE_SGIX is greater than the value 309 of PACK_MAX_COMPRESSED_SIZE_SGIX, the error INVALID_OPERATION 310 is generated. If this occurs, the contents of the first 311 PACK_MAX_COMPRESSED_SIZE_SGIX bytes after the <data> pointer 312 are undefined, but bytes outside this range are guaranteed to 313 be left unchanged. 314 315Additions to Chapter 5 of the 1.0 Specification (Special Functions) 316 317 None. 318 319Additions to Chapter 6 of the 1.0 Specification (State and State Requests) 320 321 XXX 322 323Additions to the GLX Specification 324 325 326Errors 327 328 XXX 329 330 INVALID_OPERATION is generated if the compressed data requested by a 331 ReadPixels or GetTexImage will occupy more than 332 PACK_MAX_COMPRESSED_SIZE bytes. 333 334 335 336 337New State 338 339 Get Value Get Command Type Initial Value Attribute 340 --------- ----------- ---- ------------- --------- 341 UNPACK_COMPRESSION_TYPE GetIntegerv Z1* NONE client 342 UNPACK_COMPRESSED_SIZE GetIntegerv Z+ 0 client 343 UNPACK_SAMPLE_SGIX GetIntegerv Z4 SAMPLE_444_SGIX client 344 UNPACK_TO_RGB_SGIX GetBooleanv B TRUE client 345 PACK_COMPRESSION_TYPE GetIntegerv Z1 NONE client 346 PACK_COMPRESSED_SIZE GetIntegerv Z+ 0 client 347 PACK_MAX_COMPRESSED_SIZE GetIntegerv Z+ 0 client 348 PACK_SAMPLE_SGIX GetIntegerv Z4 SAMPLE_444_SGIX client 349 PACK_FROM_RGB_SGIX GetBooleanv B TRUE client 350 351 352New Implementation Dependent State 353 354 None. 355