1Name
2
3    APPLE_rgb_422
4
5Name Strings
6
7    GL_APPLE_rgb_422
8
9Contact
10
11    Ken Dyke, Apple (kdyke 'at' apple.com)
12
13Status
14
15    Shipping as of August 28, 2009 (Mac OS X v10.6)
16
17Version
18
19    Last Modified Date: June 26, 2013
20    Version:            1.5
21
22Number
23
24    OpenGL Extension #373
25    OpenGL ES Extension #76
26
27Dependencies
28
29    OpenGL 2.0 or ARB_fragment_program is required when the GL is OpenGL.
30    OpenGL ES 2.0 is required when the GL is OpenGL ES.
31    Written against OpenGL 2.0.
32    There are interactions with OpenGL ES 2.0 and 3.0.
33
34Overview
35
36    A common storage format for video data is 8-bit 422, with every four
37    bytes encoding two pixels.   Within the four bytes there are two
38    luminance samples, and two chrominance samples that are shared between
39    both pixels.
40
41    There is a previous extension, namely GL_APPLE_ycbcr_422 that provided
42    transparent support for this kind of data.   However, that extension
43    left the exact conversion from Y'CbCr to RGB undefined.  In reality,
44    it really had always been based on the ITU-R BT.601 standard, which 
45    meant it was not particularly useful for dealing with high definition
46    video data, which is encoded using the Rec. 709 standard.
47
48    In some cases the original extension was implemented via fixed function
49    hardware, but on more modern graphics processors this is done via
50    a combination of 422 sampling formats and fragment shader instructions.
51
52    This extension essentially exposes a "raw" 422 texture format that 
53    allows developers to access the raw pre-converted Y'CbCr components
54    so that they have full control over the colorspace conversion.
55
56    In order to avoid defining entirely new color channels within GL,
57    the Y, Cb and Cr color channels within the 422 data are mapped into
58    the existing green, blue and red color channels, respectively.  Developers
59    must write their own fragment shader/program to perform the desired
60    color space transformation.
61
62    Note: Because of the use of the packed UNSIGNED_SHORT_8_8[_REV] types, the
63    correct type to use based on the layout of the data in memory (Cb Y Cr Y 
64    versus Y Cb Y Cr) will necessarily be sensitive to host endianness.
65
66    This extension differs from the EXT_422_pixels extension in a couple of
67    ways.   First, this extension defines only a single new format, while
68    relying on two new type arguments to differentiate between the two
69    component orderings.  Second, this extension provides no defined method
70    of filtering the chroma values between adjacent pixels.   And lastly,
71    the color channel assignments are slightly different, essentially to
72    match more closely the rough meanings of the Y, Cb and Cr values in 
73    422 video data.
74
75New Procedures and Functions
76
77    None
78
79New Tokens
80
81    Accepted by the <format> parameter of DrawPixels, ReadPixels, TexImage1D,
82    TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D,
83    TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
84    ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D, 
85    GetSeparableFilter, ColorTable, and GetColorTable:
86    
87      RGB_422_APPLE                 0x8A1F
88      
89	Accepted by the <internalformat> parameter of TexImage2D, TexImage3D,
90	CopyTexImage2D, TexStorage2D, and TexStorage3D:
91	
92      RGB_RAW_422_APPLE             0x8A51      
93
94    Accepted by the <type> parameter of DrawPixels, ReadPixels, TexImage1D,
95    TexImage2D, GetTexImage, TexImage3D, TexSubImage1D, TexSubImage2D,
96    TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
97    ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D, 
98    GetSeparableFilter, ColorTable, and GetColorTable:
99    
100      UNSIGNED_SHORT_8_8_APPLE        0x85BA
101      UNSIGNED_SHORT_8_8_REV_APPLE    0x85BB
102
103Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization)
104
105    Two entries are added to Table 3.5 (DrawPixels and ReadPixels type 
106    parameter values and the corresponding OpenGL data types):
107
108    type Parameter                Corresponding         Special
109      Token Name                  GL Data Type       Interpretation
110    --------------                -------------      --------------
111    UNSIGNED_SHORT_8_8_APPLE         ushort               Yes
112    UNSIGNED_SHORT_8_8_REV_APPLE     ushort               Yes
113
114
115    One entry is added to Table 3.6 (DrawPixels and ReadPixels formats):
116
117    Format Name       Element Meaning and Order         Target Buffer
118    -----------       -------------------------         ------------
119    RGB_422_APPLE     G,B     even column pixels        Color
120                      G,R     odd column pixels
121
122
123    Two entries are added to Table 3.8 (Packed pixel formats):
124    
125    type Parameter                 GL Data    Number of        Matching
126      Token Name                    Type      Components     Pixel Formats
127    --------------                 -------    ----------     -------------
128    UNSIGNED_SHORT_8_8_APPLE       ushort         2          RGB_422_APPLE
129    UNSIGNED_SHORT_8_8_REV_APPLE   ushort         2          RGB_422_APPLE
130
131
132    Two entries are added to Table 3.10 (UNSIGNED SHORT formats):
133    
134    UNSIGNED_SHORT_8_8_APPLE:
135
136          15  14  13  12  11  10  9   8   7   6   5   4   3   2   1   0
137        +-------------------------------+-------------------------------+
138        |              1st              |              2nd              |
139        +-------------------------------+-------------------------------+
140                        
141
142    UNSIGNED_SHORT_8_8_REV_APPLE:
143
144          15  14  13  12  11  10  9   8   7   6   5   4   3   2   1   0
145        +-------------------------------+-------------------------------+
146        |              2nd              |              1st              |
147        +-------------------------------+-------------------------------+
148
149
150    One entry is added to Table 3.12 (Packed pixel field assignments):
151
152                       First      Second      Third      Fourth
153    Format             Element    Element     Element    Element
154    ------             -------    -------     -------    -------
155    RGB_422_APPLE      green      blue/red
156    
157    Add the following second paragraph to the end of the section entitled
158    "Conversion to RGB":
159    
160    If the format is RGB_422_APPLE, pixels are unpacked in pairs.  For
161    even column pixels, the green and blue components are unpacked from the
162    even column pixel, and the red component is taken from the following odd
163    column pixel.   For odd column pixels, the green and red components are
164    unpacked from the odd column pixel, and the blue component is unpacked
165    from the previous even column pixel.  The row length must be even or
166    INVALID_OPERATION is generated.
167        
168Additions to the GLX Specification
169
170    None
171
172GLX Protocol
173
174    None
175
176Dependencies on OpenGL ES 2.0
177
178    If the GL is OpenGL ES, RGB_422_APPLE format textures may not be used
179    in conjunction with mipmapping or repeat wrap modes.  Add to the list
180    of conditions in section 3.8.2 under which (0,0,0,1) will be returned 
181    from a sampler:
182    
183      - A two-dimensional sampler is called, the corresponding texture image 
184        has format RGB_422_APPLE, and either the texture wrap mode is not 
185        CLAMP_TO_EDGE, or the minification filter is neither NEAREST nor 
186        LINEAR.
187        
188    Also, RGB_422_APPLE format textures may not be used as cube maps.  The
189    following error condition is introduced:
190
191      - INVALID_OPERATION is generated by TexImage2D, TexSubImage2D, and 
192        CopyTexImage2D if <format> is RGB_422_APPLE and <target> is
193        TEXTURE_CUBE_MAP_*.
194    
195    Changes to OpenGL 2.0's Table 3.5 above are made to OpenGL ES 2.0's Table 
196    3.2 (TexImage2D and ReadPixels <type> parameter values and the 
197    corresponding GL data types.)  Changes to OpenGL 2.0's Table 3.6 above are 
198    made to OpenGL ES 2.0's Table 3.3 (TexImage2D and ReadPixels formats).  
199    Changes to OpenGL 2.0's Table 3.8 above are made to OpenGL ES 2.0's Table 
200    3.5 (Packed pixel formats).  Changes to OpenGL 2.0's Table 3.10 above are 
201    made to OpenGL ES 2.0's Table 3.6 (UNSIGNED_SHORT formats).  Changes to 
202    OpenGL 2.0's Table 3.13 are made to OpenGL ES 2.0's Table 3.7 (Packed 
203    pixel field assignments).
204
205    Mentions of DrawPixels, ReadPixels, TexImage1D, TexImage3D, GetTexImage, 
206    TexSubImage1D, TexSubImage3D, GetHistogram, GetMinmax, ConvolutionFilter1D,
207    ConvolutionFilter2D, GetConvolutionFilter, SeparableFilter2D, 
208    GetSeparableFilter, ColorTable, and GetColorTable in this extension 
209    specification can be ignored for OpenGL ES.
210    
211    Mentions of TexStorage* and RGB_RAW_422_APPLE can be ignored unless EXT_texture_storage is present.
212    
213Dependencies on OpenGL ES 3.0
214
215    All of the same dependencies for OpenGL ES 2.0 also exist for OpenGL ES 3.0
216    except that TexImage3D and TexSubImage3D do apply here.
217    
218    Changes to OpenGL 2.0's Table 3.5 above are made to OpenGL ES 3.0's Table 
219    3.4 (Pixel data <type> parameter values and the corresponding GL data 
220    types.)  Changes to OpenGL 2.0's Table 3.6 above are made to OpenGL ES 
221    3.0's Table 3.5 (Pixel data formats).  Changes to OpenGL 2.0's Table 3.8 
222    above are made to OpenGL ES 3.0's Table 3.6 (Packed pixel formats).  
223    Changes to OpenGL 2.0's Table 3.10 above are made to OpenGL ES 3.0's Table 
224    3.7 (UNSIGNED_SHORT formats).  Changes to OpenGL 2.0's Table 3.13 are made 
225    to OpenGL ES 3.0's Table 3.10 (Packed pixel field assignments).
226    
227    When the GL is OpenGL ES 3.0, the following table entries are added to Table 
228    3.2:
229    
230        Format         Type                          External Bytes per Pixel  Internal Format
231        -------------  ----------------------------  ------------------------  -----------------
232        RGB_422_APPLE  UNSIGNED_SHORT_8_8_APPLE      2                         RGB_RAW_422_APPLE
233        RGB_422_APPLE  UNSIGNED_SHORT_8_8_REV_APPLE  2                         RGB_RAW_422_APPLE
234
235    When the GL is OpenGL ES 3.0, RGB_422_APPLE is also added to the Texture-only 
236    color formats list in the Required Texture Formats subsection of section 
237    3.8.3.
238    
239    If the GL is not OpenGL ES 3.0 and the EXT_texture_storage extension is not
240    present, omit references to RGB_RAW_422_APPLE and TexStorage*.
241
242    Details of how this extension interacts with EXT_texture_storage when the 
243    GL is a version of OpenGL earlier than 3.0 can be found in the 
244    EXT_texture_storage spec.
245    
246Errors
247
248    INVALID_OPERATION is generated if <format> is RGB_422_APPLE and <type> is
249    not one of UNSIGNED_SHORT_8_8_APPLE or UNSIGNED_SHORT_8_8_REV_APPLE.
250
251    INVALID_OPERATION is generated if <type> is UNSIGNED_SHORT_8_8_APPLE or 
252    UNSIGNED_SHORT_8_8_REV_APPLE and <format> is not RGB_422_APPLE.
253    
254    INVALID_OPERATION is generated if <format> is RGB_422_APPLE and <width>
255    is not even.
256
257New State
258
259    None
260
261New Implementation Dependent State
262
263    None
264
265Revision History
266
267    1.5  2013/06/26  lipchak  Add ES3 interactions
268    1.4  2010/04/06  lipchak  Add ES interactions
269    1.3  2009/09/03  kdyke    First shipping version
270
271