summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLajos Molnar2016-01-15 17:42:41 -0600
committerLajos Molnar2016-02-09 18:21:37 -0600
commit9136922045978385be99b0171c2c873aa6c2e186 (patch)
tree239b41dfb04da679aeda26536c8ad040b40783e6 /include/system
parentc31f1f3f6eb240edee5dffffce0156a6e969d223 (diff)
downloadplatform-system-core-9136922045978385be99b0171c2c873aa6c2e186.tar.gz
platform-system-core-9136922045978385be99b0171c2c873aa6c2e186.tar.xz
platform-system-core-9136922045978385be99b0171c2c873aa6c2e186.zip
Expand HAL_DATASPACE to include range, standard and transfer bitfields
Bug: 25975353 Change-Id: Id2668508b523130e5fa3496440d9423682b31632
Diffstat (limited to 'include/system')
-rw-r--r--include/system/graphics.h457
1 files changed, 369 insertions, 88 deletions
diff --git a/include/system/graphics.h b/include/system/graphics.h
index ac5ae96d4..e2556146d 100644
--- a/include/system/graphics.h
+++ b/include/system/graphics.h
@@ -553,6 +553,37 @@ typedef enum android_transform {
553 * which describes both gamma curve and numeric range (within the bit depth). 553 * which describes both gamma curve and numeric range (within the bit depth).
554 * 554 *
555 * Other dataspaces include depth measurement data from a depth camera. 555 * Other dataspaces include depth measurement data from a depth camera.
556 *
557 * A dataspace is comprised of a number of fields.
558 *
559 * Version
560 * --------
561 * The top 2 bits represent the revision of the field specification. This is
562 * currently always 0.
563 *
564 *
565 * bits 31-30 29 - 0
566 * +-----+----------------------------------------------------+
567 * fields | Rev | Revision specific fields |
568 * +-----+----------------------------------------------------+
569 *
570 * Field layout for version = 0:
571 * ----------------------------
572 *
573 * A dataspace is comprised of the following fields:
574 * Standard
575 * Transfer function
576 * Range
577 *
578 * bits 31-30 29-27 26 - 22 21 - 16 15 - 0
579 * +-----+-----+--------+--------+----------------------------+
580 * fields | 0 |Range|Transfer|Standard| Legacy and custom |
581 * +-----+-----+--------+--------+----------------------------+
582 * VV RRR TTTTT SSSSSS LLLLLLLL LLLLLLLL
583 *
584 * If range, transfer and standard fields are all 0 (e.g. top 16 bits are
585 * all zeroes), the bottom 16 bits contain either a legacy dataspace value,
586 * or a custom value.
556 */ 587 */
557 588
558typedef enum android_dataspace { 589typedef enum android_dataspace {
@@ -581,14 +612,309 @@ typedef enum android_dataspace {
581 HAL_DATASPACE_ARBITRARY = 0x1, 612 HAL_DATASPACE_ARBITRARY = 0x1,
582 613
583 /* 614 /*
584 * RGB Colorspaces 615 * Color-description aspects
585 * -----------------
586 * 616 *
587 * Primaries are given using (x,y) coordinates in the CIE 1931 definition 617 * The following aspects define various characteristics of the color
588 * of x and y specified by ISO 11664-1. 618 * specification. These represent bitfields, so that a data space value
619 * can specify each of them independently.
620 */
621
622 HAL_DATASPACE_STANDARD_SHIFT = 16,
623
624 /*
625 * Standard aspect
626 *
627 * Defines the chromaticity coordinates of the source primaries in terms of
628 * the CIE 1931 definition of x and y specified in ISO 11664-1.
629 */
630 HAL_DATASPACE_STANDARD_MASK = 63 << HAL_DATASPACE_STANDARD_SHIFT, // 0x3F
631
632 /*
633 * Chromacity coordinates are unknown or are determined by the application.
634 * Implementations shall use the following suggested standards:
635 *
636 * All YCbCr formats: BT709 if size is 720p or larger (since most video
637 * content is letterboxed this corresponds to width is
638 * 1280 or greater, or height is 720 or greater).
639 * BT601_625 if size is smaller than 720p or is JPEG.
640 * All RGB formats: BT709.
641 *
642 * For all other formats standard is undefined, and implementations should use
643 * an appropriate standard for the data represented.
644 */
645 HAL_DATASPACE_STANDARD_UNSPECIFIED = 0 << HAL_DATASPACE_STANDARD_SHIFT,
646
647 /*
648 * Primaries: x y
649 * green 0.300 0.600
650 * blue 0.150 0.060
651 * red 0.640 0.330
652 * white (D65) 0.3127 0.3290
653 *
654 * Use the unadjusted KR = 0.2126, KB = 0.0722 luminance interpretation
655 * for RGB conversion.
656 */
657 HAL_DATASPACE_STANDARD_BT709 = 1 << HAL_DATASPACE_STANDARD_SHIFT,
658
659 /*
660 * Primaries: x y
661 * green 0.290 0.600
662 * blue 0.150 0.060
663 * red 0.640 0.330
664 * white (D65) 0.3127 0.3290
665 *
666 * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
667 * for RGB conversion from the one purely determined by the primaries
668 * to minimize the color shift into RGB space that uses BT.709
669 * primaries.
670 */
671 HAL_DATASPACE_STANDARD_BT601_625 = 2 << HAL_DATASPACE_STANDARD_SHIFT,
672
673 /*
674 * Primaries: x y
675 * green 0.290 0.600
676 * blue 0.150 0.060
677 * red 0.640 0.330
678 * white (D65) 0.3127 0.3290
679 *
680 * Use the unadjusted KR = 0.222, KB = 0.071 luminance interpretation
681 * for RGB conversion.
682 */
683 HAL_DATASPACE_STANDARD_BT601_625_UNADJUSTED = 3 << HAL_DATASPACE_STANDARD_SHIFT,
684
685 /*
686 * Primaries: x y
687 * green 0.310 0.595
688 * blue 0.155 0.070
689 * red 0.630 0.340
690 * white (D65) 0.3127 0.3290
691 *
692 * KR = 0.299, KB = 0.114. This adjusts the luminance interpretation
693 * for RGB conversion from the one purely determined by the primaries
694 * to minimize the color shift into RGB space that uses BT.709
695 * primaries.
696 */
697 HAL_DATASPACE_STANDARD_BT601_525 = 4 << HAL_DATASPACE_STANDARD_SHIFT,
698
699 /*
700 * Primaries: x y
701 * green 0.310 0.595
702 * blue 0.155 0.070
703 * red 0.630 0.340
704 * white (D65) 0.3127 0.3290
705 *
706 * Use the unadjusted KR = 0.212, KB = 0.087 luminance interpretation
707 * for RGB conversion (as in SMPTE 240M).
708 */
709 HAL_DATASPACE_STANDARD_BT601_525_UNADJUSTED = 5 << HAL_DATASPACE_STANDARD_SHIFT,
710
711 /*
712 * Primaries: x y
713 * green 0.170 0.797
714 * blue 0.131 0.046
715 * red 0.708 0.292
716 * white (D65) 0.3127 0.3290
717 *
718 * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
719 * for RGB conversion.
720 */
721 HAL_DATASPACE_STANDARD_BT2020 = 6 << HAL_DATASPACE_STANDARD_SHIFT,
722
723 /*
724 * Primaries: x y
725 * green 0.170 0.797
726 * blue 0.131 0.046
727 * red 0.708 0.292
728 * white (D65) 0.3127 0.3290
729 *
730 * Use the unadjusted KR = 0.2627, KB = 0.0593 luminance interpretation
731 * for RGB conversion using the linear domain.
732 */
733 HAL_DATASPACE_STANDARD_BT2020_CONSTANT_LUMINANCE = 7 << HAL_DATASPACE_STANDARD_SHIFT,
734
735 /*
736 * Primaries: x y
737 * green 0.21 0.71
738 * blue 0.14 0.08
739 * red 0.67 0.33
740 * white (C) 0.310 0.316
741 *
742 * Use the unadjusted KR = 0.30, KB = 0.11 luminance interpretation
743 * for RGB conversion.
744 */
745 HAL_DATASPACE_STANDARD_BT470M = 8 << HAL_DATASPACE_STANDARD_SHIFT,
746
747 /*
748 * Primaries: x y
749 * green 0.243 0.692
750 * blue 0.145 0.049
751 * red 0.681 0.319
752 * white (C) 0.310 0.316
753 *
754 * Use the unadjusted KR = 0.254, KB = 0.068 luminance interpretation
755 * for RGB conversion.
756 */
757 HAL_DATASPACE_STANDARD_FILM = 9 << HAL_DATASPACE_STANDARD_SHIFT,
758
759 HAL_DATASPACE_TRANSFER_SHIFT = 22,
760
761 /*
762 * Transfer aspect
589 * 763 *
590 * Transfer characteristics are the opto-electronic transfer characteristic 764 * Transfer characteristics are the opto-electronic transfer characteristic
591 * at the source as a function of linear optical intensity (luminance). 765 * at the source as a function of linear optical intensity (luminance).
766 *
767 * For digital signals, E corresponds to the recorded value. Normally, the
768 * transfer function is applied in RGB space to each of the R, G and B
769 * components independently. This may result in color shift that can be
770 * minized by applying the transfer function in Lab space only for the L
771 * component. Implementation may apply the transfer function in RGB space
772 * for all pixel formats if desired.
773 */
774
775 HAL_DATASPACE_TRANSFER_MASK = 31 << HAL_DATASPACE_TRANSFER_SHIFT, // 0x1F
776
777 /*
778 * Transfer characteristics are unknown or are determined by the
779 * application.
780 *
781 * Implementations should use the following transfer functions:
782 *
783 * For YCbCr formats: use HAL_DATASPACE_TRANSFER_SMPTE_170M
784 * For RGB formats: use HAL_DATASPACE_TRANSFER_SRGB
785 *
786 * For all other formats transfer function is undefined, and implementations
787 * should use an appropriate standard for the data represented.
788 */
789 HAL_DATASPACE_TRANSFER_UNSPECIFIED = 0 << HAL_DATASPACE_TRANSFER_SHIFT,
790
791 /*
792 * Transfer characteristic curve:
793 * E = L
794 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
795 * E - corresponding electrical signal
796 */
797 HAL_DATASPACE_TRANSFER_LINEAR = 1 << HAL_DATASPACE_TRANSFER_SHIFT,
798
799 /*
800 * Transfer characteristic curve:
801 *
802 * E = 1.055 * L^(1/2.4) - 0.055 for 0.0031308 <= L <= 1
803 * = 12.92 * L for 0 <= L < 0.0031308
804 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
805 * E - corresponding electrical signal
806 */
807 HAL_DATASPACE_TRANSFER_SRGB = 2 << HAL_DATASPACE_TRANSFER_SHIFT,
808
809 /*
810 * BT.601 525, BT.601 625, BT.709, BT.2020
811 *
812 * Transfer characteristic curve:
813 * E = 1.099 * L ^ 0.45 - 0.099 for 0.018 <= L <= 1
814 * = 4.500 * L for 0 <= L < 0.018
815 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
816 * E - corresponding electrical signal
817 */
818 HAL_DATASPACE_TRANSFER_SMPTE_170M = 3 << HAL_DATASPACE_TRANSFER_SHIFT,
819
820 /*
821 * Assumed display gamma 2.2.
822 *
823 * Transfer characteristic curve:
824 * E = L ^ (1/2.2)
825 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
826 * E - corresponding electrical signal
827 */
828 HAL_DATASPACE_TRANSFER_GAMMA2_2 = 4 << HAL_DATASPACE_TRANSFER_SHIFT,
829
830 /*
831 * display gamma 2.8.
832 *
833 * Transfer characteristic curve:
834 * E = L ^ (1/2.8)
835 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
836 * E - corresponding electrical signal
837 */
838 HAL_DATASPACE_TRANSFER_GAMMA2_8 = 5 << HAL_DATASPACE_TRANSFER_SHIFT,
839
840 /*
841 * SMPTE ST 2084
842 *
843 * Transfer characteristic curve:
844 * E = ((c1 + c2 * L^n) / (1 + c3 * L^n)) ^ m
845 * c1 = c3 - c2 + 1 = 3424 / 4096 = 0.8359375
846 * c2 = 32 * 2413 / 4096 = 18.8515625
847 * c3 = 32 * 2392 / 4096 = 18.6875
848 * m = 128 * 2523 / 4096 = 78.84375
849 * n = 0.25 * 2610 / 4096 = 0.1593017578125
850 * L - luminance of image 0 <= L <= 1 for HDR colorimetry.
851 * L = 1 corresponds to 10000 cd/m2
852 * E - corresponding electrical signal
853 */
854 HAL_DATASPACE_TRANSFER_ST2084 = 6 << HAL_DATASPACE_TRANSFER_SHIFT,
855
856 /*
857 * ARIB STD-B67 Hybrid Log Gamma
858 *
859 * Transfer characteristic curve:
860 * E = r * L^0.5 for 0 <= L <= 1
861 * = a * ln(L - b) + c for 1 < L
862 * a = 0.17883277
863 * b = 0.28466892
864 * c = 0.55991073
865 * r = 0.5
866 * L - luminance of image 0 <= L for HDR colorimetry. L = 1 corresponds
867 * to reference white level of 100 cd/m2
868 * E - corresponding electrical signal
869 */
870 HAL_DATASPACE_TRANSFER_HLG = 7 << HAL_DATASPACE_TRANSFER_SHIFT,
871
872 HAL_DATASPACE_RANGE_SHIFT = 27,
873
874 /*
875 * Range aspect
876 *
877 * Defines the range of values corresponding to the unit range of 0-1.
878 * This is defined for YCbCr only, but can be expanded to RGB space.
879 */
880 HAL_DATASPACE_RANGE_MASK = 7 << HAL_DATASPACE_RANGE_SHIFT, // 0x7
881
882 /*
883 * Range is unknown or are determined by the application. Implementations
884 * shall use the following suggested ranges:
885 *
886 * All YCbCr formats: limited range.
887 * All RGB or RGBA formats (including RAW and Bayer): full range.
888 * All Y formats: full range
889 *
890 * For all other formats range is undefined, and implementations should use
891 * an appropriate range for the data represented.
892 */
893 HAL_DATASPACE_RANGE_UNSPECIFIED = 0 << HAL_DATASPACE_RANGE_SHIFT,
894
895 /*
896 * Full range uses all values for Y, Cb and Cr from
897 * 0 to 2^b-1, where b is the bit depth of the color format.
898 */
899 HAL_DATASPACE_RANGE_FULL = 1 << HAL_DATASPACE_RANGE_SHIFT,
900
901 /*
902 * Limited range uses values 16/256*2^b to 235/256*2^b for Y, and
903 * 1/16*2^b to 15/16*2^b for Cb, Cr, R, G and B, where b is the bit depth of
904 * the color format.
905 *
906 * E.g. For 8-bit-depth formats:
907 * Luma (Y) samples should range from 16 to 235, inclusive
908 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
909 *
910 * For 10-bit-depth formats:
911 * Luma (Y) samples should range from 64 to 940, inclusive
912 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
913 */
914 HAL_DATASPACE_RANGE_LIMITED = 2 << HAL_DATASPACE_RANGE_SHIFT,
915
916 /*
917 * Legacy dataspaces
592 */ 918 */
593 919
594 /* 920 /*
@@ -601,34 +927,30 @@ typedef enum android_dataspace {
601 * The values are encoded using the full range ([0,255] for 8-bit) for all 927 * The values are encoded using the full range ([0,255] for 8-bit) for all
602 * components. 928 * components.
603 */ 929 */
604 HAL_DATASPACE_SRGB_LINEAR = 0x200, 930 HAL_DATASPACE_SRGB_LINEAR_LEGACY = 0x200,
931
932 HAL_DATASPACE_SRGB_LINEAR = HAL_DATASPACE_STANDARD_BT709 |
933 HAL_DATASPACE_TRANSFER_LINEAR | HAL_DATASPACE_RANGE_FULL,
934
605 935
606 /* 936 /*
607 * sRGB gamma encoding: 937 * sRGB gamma encoding:
608 * 938 *
609 * The red, green and blue components are stored in sRGB space, and 939 * The red, green and blue components are stored in sRGB space, and
610 * converted to linear space when read, using the standard sRGB to linear 940 * converted to linear space when read, using the SRGB transfer function
611 * equation: 941 * for each of the R, G and B components. When written, the inverse
612 * 942 * transformation is performed.
613 * Clinear = Csrgb / 12.92 for Csrgb <= 0.04045
614 * = (Csrgb + 0.055 / 1.055)^2.4 for Csrgb > 0.04045
615 *
616 * When written the inverse transformation is performed:
617 *
618 * Csrgb = 12.92 * Clinear for Clinear <= 0.0031308
619 * = 1.055 * Clinear^(1/2.4) - 0.055 for Clinear > 0.0031308
620 *
621 * 943 *
622 * The alpha component, if present, is always stored in linear space and 944 * The alpha component, if present, is always stored in linear space and
623 * is left unmodified when read or written. 945 * is left unmodified when read or written.
624 * 946 *
625 * The RGB primaries and the white point are the same as BT.709. 947 * Use full range and BT.709 standard.
626 *
627 * The values are encoded using the full range ([0,255] for 8-bit) for all
628 * components.
629 *
630 */ 948 */
631 HAL_DATASPACE_SRGB = 0x201, 949 HAL_DATASPACE_SRGB_LEGACY = 0x201,
950
951 HAL_DATASPACE_SRGB = HAL_DATASPACE_STANDARD_BT709 |
952 HAL_DATASPACE_TRANSFER_SRGB | HAL_DATASPACE_RANGE_FULL,
953
632 954
633 /* 955 /*
634 * YCbCr Colorspaces 956 * YCbCr Colorspaces
@@ -646,94 +968,53 @@ typedef enum android_dataspace {
646 * 968 *
647 * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255 969 * Same model as BT.601-625, but all values (Y, Cb, Cr) range from 0 to 255
648 * 970 *
649 * Transfer characteristic curve: 971 * Use full range, BT.601 transfer and BT.601_625 standard.
650 * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
651 * E = 4.500 L, 0.018 > L >= 0
652 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
653 * E - corresponding electrical signal
654 *
655 * Primaries: x y
656 * green 0.290 0.600
657 * blue 0.150 0.060
658 * red 0.640 0.330
659 * white (D65) 0.3127 0.3290
660 */ 972 */
661 HAL_DATASPACE_JFIF = 0x101, 973 HAL_DATASPACE_JFIF_LEGACY = 0x101,
974
975 HAL_DATASPACE_JFIF = HAL_DATASPACE_STANDARD_BT601_625 |
976 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_FULL,
662 977
663 /* 978 /*
664 * ITU-R Recommendation 601 (BT.601) - 625-line 979 * ITU-R Recommendation 601 (BT.601) - 625-line
665 * 980 *
666 * Standard-definition television, 625 Lines (PAL) 981 * Standard-definition television, 625 Lines (PAL)
667 * 982 *
668 * For 8-bit-depth formats: 983 * Use limited range, BT.601 transfer and BT.601_625 standard.
669 * Luma (Y) samples should range from 16 to 235, inclusive
670 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
671 *
672 * For 10-bit-depth formats:
673 * Luma (Y) samples should range from 64 to 940, inclusive
674 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
675 *
676 * Transfer characteristic curve:
677 * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
678 * E = 4.500 L, 0.018 > L >= 0
679 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
680 * E - corresponding electrical signal
681 *
682 * Primaries: x y
683 * green 0.290 0.600
684 * blue 0.150 0.060
685 * red 0.640 0.330
686 * white (D65) 0.3127 0.3290
687 */ 984 */
688 HAL_DATASPACE_BT601_625 = 0x102, 985 HAL_DATASPACE_BT601_625_LEGACY = 0x102,
986
987 HAL_DATASPACE_BT601_625 = HAL_DATASPACE_STANDARD_BT601_625 |
988 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED,
989
689 990
690 /* 991 /*
691 * ITU-R Recommendation 601 (BT.601) - 525-line 992 * ITU-R Recommendation 601 (BT.601) - 525-line
692 * 993 *
693 * Standard-definition television, 525 Lines (NTSC) 994 * Standard-definition television, 525 Lines (NTSC)
694 * 995 *
695 * For 8-bit-depth formats: 996 * Use limited range, BT.601 transfer and BT.601_525 standard.
696 * Luma (Y) samples should range from 16 to 235, inclusive
697 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive
698 *
699 * For 10-bit-depth formats:
700 * Luma (Y) samples should range from 64 to 940, inclusive
701 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive
702 *
703 * Transfer characteristic curve:
704 * E = 1.099 * L ^ 0.45 - 0.099, 1.00 >= L >= 0.018
705 * E = 4.500 L, 0.018 > L >= 0
706 * L - luminance of image 0 <= L <= 1 for conventional colorimetry
707 * E - corresponding electrical signal
708 *
709 * Primaries: x y
710 * green 0.310 0.595
711 * blue 0.155 0.070
712 * red 0.630 0.340
713 * white (D65) 0.3127 0.3290
714 */ 997 */
715 HAL_DATASPACE_BT601_525 = 0x103, 998 HAL_DATASPACE_BT601_525_LEGACY = 0x103,
999
1000 HAL_DATASPACE_BT601_525 = HAL_DATASPACE_STANDARD_BT601_525 |
1001 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED,
716 1002
717 /* 1003 /*
718 * ITU-R Recommendation 709 (BT.709) 1004 * ITU-R Recommendation 709 (BT.709)
719 * 1005 *
720 * High-definition television 1006 * High-definition television
721 * 1007 *
722 * For 8-bit-depth formats: 1008 * Use limited range, BT.709 transfer and BT.709 standard.
723 * Luma (Y) samples should range from 16 to 235, inclusive 1009 */
724 * Chroma (Cb, Cr) samples should range from 16 to 240, inclusive 1010 HAL_DATASPACE_BT709_LEGACY = 0x104,
725 * 1011
726 * For 10-bit-depth formats: 1012 HAL_DATASPACE_BT709 = HAL_DATASPACE_STANDARD_BT709 |
727 * Luma (Y) samples should range from 64 to 940, inclusive 1013 HAL_DATASPACE_TRANSFER_SMPTE_170M | HAL_DATASPACE_RANGE_LIMITED,
728 * Chroma (Cb, Cr) samples should range from 64 to 960, inclusive 1014
729 * 1015 /*
730 * Primaries: x y 1016 * Data spaces for non-color formats
731 * green 0.300 0.600
732 * blue 0.150 0.060
733 * red 0.640 0.330
734 * white (D65) 0.3127 0.3290
735 */ 1017 */
736 HAL_DATASPACE_BT709 = 0x104,
737 1018
738 /* 1019 /*
739 * The buffer contains depth ranging measurements from a depth camera. 1020 * The buffer contains depth ranging measurements from a depth camera.