11
22function XYZ_to_ICtCp ( XYZ ) {
3- // convert an array of absolute, D65 XYZ to the ICtCp form of LMS
3+ // convert an array of absolute, D65 XYZ to the ICtCp form of LMS
44
55 // The matrix below includes the 4% crosstalk components
66 // and is from the procedure in the Dolby "What is ICtCp" paper"
@@ -32,17 +32,17 @@ function LMStoICtCp (LMS) {
3232 [ 17933 / 4096 , - 17390 / 4096 , - 543 / 4096 ] ,
3333 ] ;
3434
35- // apply the PQ EOTF
36- // we can't ever be dividing by zero because of the "1 +" in the denominator
37- let PQLMS = LMS . map ( function ( val ) {
38- let num = c1 + ( c2 * ( ( val / 10000 ) ** m1 ) ) ;
39- let denom = 1 + ( c3 * ( ( val / 10000 ) ** m1 ) ) ;
35+ // apply the PQ EOTF
36+ // we can't ever be dividing by zero because of the "1 +" in the denominator
37+ let PQLMS = LMS . map ( function ( val ) {
38+ let num = c1 + ( c2 * ( ( val / 10000 ) ** m1 ) ) ;
39+ let denom = 1 + ( c3 * ( ( val / 10000 ) ** m1 ) ) ;
4040
41- return ( num / denom ) ** m2 ;
42- } ) ;
41+ return ( num / denom ) ** m2 ;
42+ } ) ;
4343
44- // LMS to IPT, with rotation for Y'C'bC'r compatibility
45- return multiplyMatrices ( M , PQLMS ) ;
44+ // LMS to IPT, with rotation for Y'C'bC'r compatibility
45+ return multiplyMatrices ( M , PQLMS ) ;
4646}
4747
4848function ICtCp_to_XYZ ( ICtCp ) {
@@ -55,7 +55,7 @@ function ICtCp_to_XYZ (ICtCp) {
5555 ] ;
5656
5757 let LMS = ICtCptoLMS ( ICtCp ) ;
58- return multiplyMatrices ( M , LMS ) ;
58+ return multiplyMatrices ( M , LMS ) ;
5959}
6060
6161function ICtCptoLMS ( ICtCp ) {
@@ -72,14 +72,14 @@ function ICtCptoLMS (ICtCp) {
7272 [ 0.9999999999999998 , 0.5600313357106791 , - 0.3206271749873188 ] ,
7373 ] ;
7474
75- let PQLMS = multiplyMatrices ( M , ICtCp ) ;
75+ let PQLMS = multiplyMatrices ( M , ICtCp ) ;
7676
77- // Undo PQ encoding, From BT.2124-0 Annex 2 Conversion 3
78- let LMS = PQLMS . map ( function ( val ) {
79- let num = Math . max ( ( val ** im2 ) - c1 , 0 ) ;
80- let denom = ( c2 - ( c3 * ( val ** im2 ) ) ) ;
81- return 10000 * ( ( num / denom ) ** im1 ) ;
82- } ) ;
77+ // Undo PQ encoding, From BT.2124-0 Annex 2 Conversion 3
78+ let LMS = PQLMS . map ( function ( val ) {
79+ let num = Math . max ( ( val ** im2 ) - c1 , 0 ) ;
80+ let denom = ( c2 - ( c3 * ( val ** im2 ) ) ) ;
81+ return 10000 * ( ( num / denom ) ** im1 ) ;
82+ } ) ;
8383
84- return LMS ;
84+ return LMS ;
8585}
0 commit comments