1 module itu_h273; 2 3 4 /+ 5 6 nothrow @nogc: 7 8 /// ColourPrimaries indicates the chromaticity coordinates 9 /// of the source colour primaries as specified in Table 2 10 /// in terms of the CIE 1931 definition of x and y as 11 /// specified by ISO/CIE 11664-1. 12 13 enum ColourPrimaries : ubyte; 14 15 private struct PrimariesData 16 { 17 float x_green, y_green; 18 float x_blue, y_blue; 19 float x_red, y_red; 20 float x_white, y_white; 21 } 22 23 private PrimariesData getColourPrimaries(ColourPrimaries cp, 24 out bool reserved, 25 out bool unspecified) 26 { 27 switch (cp) 28 { 29 case 0: 30 case 3: 31 case 13: .. case 21: 32 case 23: .. case 255: 33 34 reserved = true; 35 return PrimariesData.init; 36 37 case 2: 38 unspecified = true; 39 return PrimariesData.init; 40 41 default: 42 return PRIMARIES[cp-1]; 43 } 44 45 46 47 } 48 49 private static immutable PrimariesData[22] PRIMARIES = 50 [ 51 PrimariesData(0.300, 0.600, 0.150, 0.060, 52 0.640, 0.330, 0.3127, 0.3290), 53 PrimariesData.init, 54 PrimariesData.init, 55 PrimariesData(0.210, 0.710, 0.140, 0.080, 56 0.670, 0.330, 0.3100, 0.3160), 57 58 PrimariesData(0.290, 0.600, 0.150, 0.060, 59 0.640, 0.330, 0.3127, 0.3290), 60 PrimariesData(0.310, 0.595, 0.155, 0.070, 61 0.630, 0.340, 0.3127, 0.3290), // 6 62 PrimariesData(0.310, 0.595, 0.155, 0.070, 63 0.630, 0.340, 0.3127, 0.3290), // 7 64 PrimariesData(0.243, 0.692, 0.145, 0.049, 65 0.681, 0.319, 0.310, 0.316), // Generic film 66 PrimariesData(0.170, 0.797, 0.131, 0.046, // 9 67 0.708, 0.292, 0.3127, 0.3290), 68 69 // CIE 1931 XYZ, in YZX order 70 PrimariesData(0.000, 1.000, 0.000, 0.000, // SMPTE ST 428-1 71 1.000, 0.000, 0.3333333f, 0.333333f), 72 PrimariesData(0.265, 0.690, 0.150, 0.060, 73 0.680, 0.320, 0.314f, 0.351f), 74 PrimariesData(0.265, 0.690, 0.150, 0.060, 75 0.680, 0.320, 0.3127f, 0.3290f), // 12 76 PrimariesData.init, // 13 77 PrimariesData.init, // 14 78 PrimariesData.init, // 15 79 PrimariesData.init, // 16 80 PrimariesData.init, // 17 81 PrimariesData.init, // 18 82 PrimariesData.init, // 19 83 PrimariesData.init, // 20 84 PrimariesData.init, // 21 85 PrimariesData(0.295, 0.605, 0.155, 0.077, 86 0.680, 0.340, 0.3127f, 0.3290f) 87 ]; 88 89 alias TransferCharacteristics = ubyte; 90 91 92 double transferColor(double Lc, 93 TransferCharacteristics car, 94 out bool reserved, 95 out bool unspecified) 96 { 97 switch(car) 98 { 99 case 0: 100 case 3: 101 case 19: .. case 255: 102 reserved = true; 103 break; 104 105 106 107 case 1: 108 case 6: 109 case 14: 110 case 15: 111 { 112 double alpha = 1.099296826809442; 113 double beta = 0.018053968510807; 114 if (Lc < beta) return Lc * 4.5; 115 } 116 117 case 8: 118 119 120 } 121 122 123 } 124 +/