• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * @defgroup ADataSpace Data Space
19  *
20  * ADataSpace describes how to interpret colors.
21  * @{
22  */
23 
24 /**
25  * @file data_space.h
26  */
27 
28 #ifndef ANDROID_DATA_SPACE_H
29 #define ANDROID_DATA_SPACE_H
30 
31 #include <inttypes.h>
32 
33 #include <sys/cdefs.h>
34 
35 __BEGIN_DECLS
36 
37 /**
38  * ADataSpace.
39  */
40 enum ADataSpace {
41     /**
42      * Default-assumption data space, when not explicitly specified.
43      *
44      * It is safest to assume the buffer is an image with sRGB primaries and
45      * encoding ranges, but the consumer and/or the producer of the data may
46      * simply be using defaults. No automatic gamma transform should be
47      * expected, except for a possible display gamma transform when drawn to a
48      * screen.
49      */
50     ADATASPACE_UNKNOWN = 0,
51 
52     /**
53      * Color-description aspects
54      *
55      * The following aspects define various characteristics of the color
56      * specification. These represent bitfields, so that a data space value
57      * can specify each of them independently.
58      */
59 
60     /**
61      * Standard aspect
62      *
63      * Defines the chromaticity coordinates of the source primaries in terms of
64      * the CIE 1931 definition of x and y specified in ISO 11664-1.
65      */
66     STANDARD_MASK = 63 << 16,
67 
68     /**
69      * Chromacity coordinates are unknown or are determined by the application.
70      * Implementations shall use the following suggested standards:
71      *
72      * All YCbCr formats: BT709 if size is 720p or larger (since most video
73      *                    content is letterboxed this corresponds to width is
74      *                    1280 or greater, or height is 720 or greater).
75      *                    BT601_625 if size is smaller than 720p or is JPEG.
76      * All RGB formats:   BT709.
77      *
78      * For all other formats standard is undefined, and implementations should use
79      * an appropriate standard for the data represented.
80      */
81     STANDARD_UNSPECIFIED = 0 << 16,
82 
83     /**
84      * Primaries:       x       y
85      *  green           0.300   0.600
86      *  blue            0.150   0.060
87      *  red             0.640   0.330
88      *  white (D65)     0.3127  0.3290
89      *
90      * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation
91      * for RGB conversion.
92      */
93     STANDARD_BT709 = 1 << 16,
94 
95     /**
96      * Primaries:       x       y
97      *  green           0.290   0.600
98      *  blue            0.150   0.060
99      *  red             0.640   0.330
100      *  white (D65)     0.3127  0.3290
101      *
102      *  KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
103      *  for RGB conversion from the one purely determined by the primaries
104      *  to minimize the color shift into RGB space that uses BT.709
105      *  primaries.
106      */
107     STANDARD_BT601_625 = 2 << 16,
108 
109     /**
110      * Primaries:       x       y
111      *  green           0.290   0.600
112      *  blue            0.150   0.060
113      *  red             0.640   0.330
114      *  white (D65)     0.3127  0.3290
115      *
116      * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation
117      * for RGB conversion.
118      */
119     STANDARD_BT601_625_UNADJUSTED = 3 << 16,
120 
121     /**
122      * Primaries:       x       y
123      *  green           0.310   0.595
124      *  blue            0.155   0.070
125      *  red             0.630   0.340
126      *  white (D65)     0.3127  0.3290
127      *
128      *  KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
129      *  for RGB conversion from the one purely determined by the primaries
130      *  to minimize the color shift into RGB space that uses BT.709
131      *  primaries.
132      */
133     STANDARD_BT601_525 = 4 << 16,
134 
135     /**
136      * Primaries:       x       y
137      *  green           0.310   0.595
138      *  blue            0.155   0.070
139      *  red             0.630   0.340
140      *  white (D65)     0.3127  0.3290
141      *
142      * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation
143      * for RGB conversion (as in SMPTE 240M).
144      */
145     STANDARD_BT601_525_UNADJUSTED = 5 << 16,
146 
147     /**
148      * Primaries:       x       y
149      *  green           0.170   0.797
150      *  blue            0.131   0.046
151      *  red             0.708   0.292
152      *  white (D65)     0.3127  0.3290
153      *
154      * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
155      * for RGB conversion.
156      */
157     STANDARD_BT2020 = 6 << 16,
158 
159     /**
160      * Primaries:       x       y
161      *  green           0.170   0.797
162      *  blue            0.131   0.046
163      *  red             0.708   0.292
164      *  white (D65)     0.3127  0.3290
165      *
166      * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
167      * for RGB conversion using the linear domain.
168      */
169     STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << 16,
170 
171     /**
172      * Primaries:       x      y
173      *  green           0.21   0.71
174      *  blue            0.14   0.08
175      *  red             0.67   0.33
176      *  white (C)       0.310  0.316
177      *
178      * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation
179      * for RGB conversion.
180      */
181     STANDARD_BT470M = 8 << 16,
182 
183     /**
184      * Primaries:       x       y
185      *  green           0.243   0.692
186      *  blue            0.145   0.049
187      *  red             0.681   0.319
188      *  white (C)       0.310   0.316
189      *
190      * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation
191      * for RGB conversion.
192      */
193     STANDARD_FILM = 9 << 16,
194 
195     /**
196      * SMPTE EG 432-1 and SMPTE RP 431-2. (DCI-P3)
197      * Primaries:       x       y
198      *  green           0.265   0.690
199      *  blue            0.150   0.060
200      *  red             0.680   0.320
201      *  white (D65)     0.3127  0.3290
202      */
203     STANDARD_DCI_P3 = 10 << 16,
204 
205     /**
206      * Adobe RGB
207      * Primaries:       x       y
208      *  green           0.210   0.710
209      *  blue            0.150   0.060
210      *  red             0.640   0.330
211      *  white (D65)     0.3127  0.3290
212      */
213     STANDARD_ADOBE_RGB = 11 << 16,
214 
215     /**
216      * Transfer aspect
217      *
218      * Transfer characteristics are the opto-electronic transfer characteristic
219      * at the source as a function of linear optical intensity (luminance).
220      *
221      * For digital signals, E corresponds to the recorded value. Normally, the
222      * transfer function is applied in RGB space to each of the R, G and B
223      * components independently. This may result in color shift that can be
224      * minized by applying the transfer function in Lab space only for the L
225      * component. Implementation may apply the transfer function in RGB space
226      * for all pixel formats if desired.
227      */
228     TRANSFER_MASK = 31 << 22,
229 
230     /**
231      * Transfer characteristics are unknown or are determined by the
232      * application.
233      *
234      * Implementations should use the following transfer functions:
235      *
236      * For YCbCr formats: use TRANSFER_SMPTE_170M
237      * For RGB formats: use TRANSFER_SRGB
238      *
239      * For all other formats transfer function is undefined, and implementations
240      * should use an appropriate standard for the data represented.
241      */
242     TRANSFER_UNSPECIFIED = 0 << 22,
243 
244     /**
245      * Transfer characteristic curve:
246      *  E = L
247      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
248      *      E - corresponding electrical signal
249      */
250     TRANSFER_LINEAR = 1 << 22,
251 
252     /**
253      * Transfer characteristic curve:
254      *
255      * E = 1.055 * L^(1/2.4) - 0.055  for 0.0031308 <= L <= 1
256      *   = 12.92 * L                  for 0 <= L < 0.0031308
257      *     L - luminance of image 0 <= L <= 1 for conventional colorimetry
258      *     E - corresponding electrical signal
259      */
260     TRANSFER_SRGB = 2 << 22,
261 
262     /**
263      * BT.601 525, BT.601 625, BT.709, BT.2020
264      *
265      * Transfer characteristic curve:
266      *  E = 1.099 * L ^ 0.45 - 0.099  for 0.018 <= L <= 1
267      *    = 4.500 * L                 for 0 <= L < 0.018
268      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
269      *      E - corresponding electrical signal
270      */
271     TRANSFER_SMPTE_170M = 3 << 22,
272 
273     /**
274      * Assumed display gamma 2.2.
275      *
276      * Transfer characteristic curve:
277      *  E = L ^ (1/2.2)
278      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
279      *      E - corresponding electrical signal
280      */
281     TRANSFER_GAMMA2_2 = 4 << 22,
282 
283     /**
284      *  display gamma 2.6.
285      *
286      * Transfer characteristic curve:
287      *  E = L ^ (1/2.6)
288      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
289      *      E - corresponding electrical signal
290      */
291     TRANSFER_GAMMA2_6 = 5 << 22,
292 
293     /**
294      *  display gamma 2.8.
295      *
296      * Transfer characteristic curve:
297      *  E = L ^ (1/2.8)
298      *      L - luminance of image 0 <= L <= 1 for conventional colorimetry
299      *      E - corresponding electrical signal
300      */
301     TRANSFER_GAMMA2_8 = 6 << 22,
302 
303     /**
304      * SMPTE ST 2084 (Dolby Perceptual Quantizer)
305      *
306      * Transfer characteristic curve:
307      *  E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m
308      *  c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375
309      *  c2 = 32 * 2413 / 4096 = 18.8515625
310      *  c3 = 32 * 2392 / 4096 = 18.6875
311      *  m = 128 * 2523 / 4096 = 78.84375
312      *  n = 0.25 * 2610 / 4096 = 0.1593017578125
313      *      L - luminance of image 0 <= L <= 1 for HDR colorimetry.
314      *          L = 1 corresponds to 10000 cd/m2
315      *      E - corresponding electrical signal
316      */
317     TRANSFER_ST2084 = 7 << 22,
318 
319     /**
320      * ARIB STD-B67 Hybrid Log Gamma
321      *
322      * Transfer characteristic curve:
323      *  E = r * L^0.5                 for 0 <= L <= 1
324      *    = a * ln(L - b) + c         for 1 < L
325      *  a = 0.17883277
326      *  b = 0.28466892
327      *  c = 0.55991073
328      *  r = 0.5
329      *      L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds
330      *          to reference white level of 100 cd/m2
331      *      E - corresponding electrical signal
332      */
333     TRANSFER_HLG = 8 << 22,
334 
335     /**
336      * Range aspect
337      *
338      * Defines the range of values corresponding to the unit range of 0-1.
339      * This is defined for YCbCr only, but can be expanded to RGB space.
340      */
341     RANGE_MASK = 7 << 27,
342 
343     /**
344      * Range is unknown or are determined by the application.  Implementations
345      * shall use the following suggested ranges:
346      *
347      * All YCbCr formats: limited range.
348      * All RGB or RGBA formats (including RAW and Bayer): full range.
349      * All Y formats: full range
350      *
351      * For all other formats range is undefined, and implementations should use
352      * an appropriate range for the data represented.
353      */
354     RANGE_UNSPECIFIED = 0 << 27,
355 
356     /**
357      * Full range uses all values for Y, Cb and Cr from
358      * 0 to 2^b-1, where b is the bit depth of the color format.
359      */
360     RANGE_FULL = 1 << 27,
361 
362     /**
363      * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and
364      * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of
365      * the color format.
366      *
367      * E.g. For 8-bit-depth formats:
368      * Luma (Y) samples should range from 16 to 235, inclusive
369      * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
370      *
371      * For 10-bit-depth formats:
372      * Luma (Y) samples should range from 64 to 940, inclusive
373      * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
374      */
375     RANGE_LIMITED = 2 << 27,
376 
377     /**
378      * Extended range is used for scRGB. Intended for use with
379      * floating point pixel formats. [0.0 - 1.0] is the standard
380      * sRGB space. Values outside the range 0.0 - 1.0 can encode
381      * color outside the sRGB gamut.
382      * Used to blend / merge multiple dataspaces on a single display.
383      */
384     RANGE_EXTENDED = 3 << 27,
385 
386     /**
387      * scRGB linear encoding:
388      *
389      * The red, green, and blue components are stored in extended sRGB space,
390      * but are linear, not gamma-encoded.
391      * The RGB primaries and the white point are the same as BT.709.
392      *
393      * The values are floating point.
394      * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits.
395      * Values beyond the range [0.0 - 1.0] would correspond to other colors
396      * spaces and/or HDR content.
397      */
398     ADATASPACE_SCRGB_LINEAR = 406913024, // STANDARD_BT709 | TRANSFER_LINEAR | RANGE_EXTENDED
399 
400     /**
401      * sRGB gamma encoding:
402      *
403      * The red, green and blue components are stored in sRGB space, and
404      * converted to linear space when read, using the SRGB transfer function
405      * for each of the R, G and B components. When written, the inverse
406      * transformation is performed.
407      *
408      * The alpha component, if present, is always stored in linear space and
409      * is left unmodified when read or written.
410      *
411      * Use full range and BT.709 standard.
412      */
413     ADATASPACE_SRGB = 142671872, // STANDARD_BT709 | TRANSFER_SRGB | RANGE_FULL
414 
415     /**
416      * scRGB:
417      *
418      * The red, green, and blue components are stored in extended sRGB space,
419      * and gamma-encoded using the SRGB transfer function.
420      * The RGB primaries and the white point are the same as BT.709.
421      *
422      * The values are floating point.
423      * A pixel value of 1.0, 1.0, 1.0 corresponds to sRGB white (D65) at 80 nits.
424      * Values beyond the range [0.0 - 1.0] would correspond to other colors
425      * spaces and/or HDR content.
426      */
427     ADATASPACE_SCRGB = 411107328, // STANDARD_BT709 | TRANSFER_SRGB | RANGE_EXTENDED
428 
429     /**
430      * Display P3
431      *
432      * Use same primaries and white-point as DCI-P3
433      * but sRGB transfer function.
434      */
435     ADATASPACE_DISPLAY_P3 = 143261696, // STANDARD_DCI_P3 | TRANSFER_SRGB | RANGE_FULL
436 
437     /**
438      * ITU-R Recommendation 2020 (BT.2020)
439      *
440      * Ultra High-definition television
441      *
442      * Use full range, SMPTE 2084 (PQ) transfer and BT2020 standard
443      */
444     ADATASPACE_BT2020_PQ = 163971072, // STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_FULL
445 
446     /**
447      * ITU-R Recommendation 2020 (BT.2020)
448      *
449      * Ultra High-definition television
450      *
451      * Use limited range, SMPTE 2084 (PQ) transfer and BT2020 standard
452      */
453     ADATASPACE_BT2020_ITU_PQ = 298188800,  // STANDARD_BT2020 | TRANSFER_ST2084 | RANGE_LIMITED
454 
455     /**
456      * Adobe RGB
457      *
458      * Use full range, gamma 2.2 transfer and Adobe RGB primaries
459      * Note: Application is responsible for gamma encoding the data as
460      * a 2.2 gamma encoding is not supported in HW.
461      */
462     ADATASPACE_ADOBE_RGB = 151715840, // STANDARD_ADOBE_RGB | TRANSFER_GAMMA2_2 | RANGE_FULL
463 
464     /**
465      * JPEG File Interchange Format (JFIF)
466      *
467      * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
468      *
469      * Use full range, SMPTE 170M transfer and BT.601_625 standard.
470      */
471     ADATASPACE_JFIF = 146931712, // STANDARD_BT601_625 | TRANSFER_SMPTE_170M | RANGE_FULL
472 
473     /**
474      * ITU-R Recommendation 601 (BT.601) - 525-line
475      *
476      * Standard-definition television, 525 Lines (NTSC)
477      *
478      * Use limited range, SMPTE 170M transfer and BT.601_525 standard.
479      */
480     ADATASPACE_BT601_625 = 281149440, // STANDARD_BT601_625 | TRANSFER_SMPTE_170M | RANGE_LIMITED
481 
482     /**
483      * ITU-R Recommendation 709 (BT.709)
484      *
485      * High-definition television
486      *
487      * Use limited range, SMPTE 170M transfer and BT.709 standard.
488      */
489     ADATASPACE_BT601_525 = 281280512, // STANDARD_BT601_525 | TRANSFER_SMPTE_170M | RANGE_LIMITED
490 
491     /**
492      * ITU-R Recommendation 2020 (BT.2020)
493      *
494      * Ultra High-definition television
495      *
496      * Use full range, BT.709 transfer and BT2020 standard
497      */
498     ADATASPACE_BT2020 = 147193856, // STANDARD_BT2020 | TRANSFER_SMPTE_170M | RANGE_FULL
499 
500     /**
501      * ITU-R Recommendation 709 (BT.709)
502      *
503      * High-definition television
504      *
505      * Use limited range, BT.709 transfer and BT.709 standard.
506      */
507     ADATASPACE_BT709 = 281083904, // STANDARD_BT709 | TRANSFER_SMPTE_170M | RANGE_LIMITED
508 
509     /**
510      * SMPTE EG 432-1 and SMPTE RP 431-2.
511      *
512      * Digital Cinema DCI-P3
513      *
514      * Use full range, gamma 2.6 transfer and D65 DCI-P3 standard
515      * Note: Application is responsible for gamma encoding the data as
516      * a 2.6 gamma encoding is not supported in HW.
517      */
518     ADATASPACE_DCI_P3 = 155844608, // STANDARD_DCI_P3 | TRANSFER_GAMMA2_6 | RANGE_FULL
519 
520     /**
521      * sRGB linear encoding:
522      *
523      * The red, green, and blue components are stored in sRGB space, but
524      * are linear, not gamma-encoded.
525      * The RGB primaries and the white point are the same as BT.709.
526      *
527      * The values are encoded using the full range ([0,255] for 8-bit) for all
528      * components.
529      */
530     ADATASPACE_SRGB_LINEAR = 138477568, // STANDARD_BT709 | TRANSFER_LINEAR | RANGE_FULL
531 
532     /**
533      * Hybrid Log Gamma encoding:
534      *
535      * Use full range, hybrid log gamma transfer and BT2020 standard.
536      */
537     ADATASPACE_BT2020_HLG = 168165376, // STANDARD_BT2020 | TRANSFER_HLG | RANGE_FULL
538 
539     /**
540      * ITU Hybrid Log Gamma encoding:
541      *
542      * Use limited range, hybrid log gamma transfer and BT2020 standard.
543      */
544     ADATASPACE_BT2020_ITU_HLG = 302383104, // STANDARD_BT2020 | TRANSFER_HLG | RANGE_LIMITED
545 
546     /**
547      * Depth:
548      *
549      * This value is valid with formats HAL_PIXEL_FORMAT_Y16 and HAL_PIXEL_FORMAT_BLOB.
550      */
551     DEPTH = 4096,
552 
553     /**
554      * ISO 16684-1:2011(E) Dynamic Depth:
555      *
556      * Embedded depth metadata following the dynamic depth specification.
557      */
558     DYNAMIC_DEPTH = 4098
559 };
560 
561 __END_DECLS
562 
563 #endif // ANDROID_DATA_SPACE_H
564 
565 /** @} */
566