jdk/src/share/native/sun/java2d/cmm/lcms/cmslut.c
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 18253 4323a5fe8bc4
child 23906 8f7f9cb6fe11
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2394
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2394
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2394
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2394
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2394
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
// This file is available under and governed by the GNU General Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
// License version 2 only, as published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
// However, the following notice accompanied the original version of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
// file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
//
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    30
//---------------------------------------------------------------------------------
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
//
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    32
//  Little Color Management System
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
    33
//  Copyright (c) 1998-2012 Marti Maria Saguer
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
// Permission is hereby granted, free of charge, to any person obtaining
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
// a copy of this software and associated documentation files (the "Software"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
// to deal in the Software without restriction, including without limitation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
// and/or sell copies of the Software, and to permit persons to whom the Software
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
// is furnished to do so, subject to the following conditions:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
// The above copyright notice and this permission notice shall be included in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
// all copies or substantial portions of the Software.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
//
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    53
//---------------------------------------------------------------------------------
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
//
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    55
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    56
#include "lcms2_internal.h"
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    57
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    58
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    59
// Allocates an empty multi profile element
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    60
cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    61
                                cmsStageSignature Type,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    62
                                cmsUInt32Number InputChannels,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    63
                                cmsUInt32Number OutputChannels,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    64
                                _cmsStageEvalFn     EvalPtr,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    65
                                _cmsStageDupElemFn  DupElemPtr,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    66
                                _cmsStageFreeElemFn FreePtr,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    67
                                void*             Data)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    68
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    69
    cmsStage* ph = (cmsStage*) _cmsMallocZero(ContextID, sizeof(cmsStage));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    70
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    71
    if (ph == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    72
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    73
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    74
    ph ->ContextID = ContextID;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    75
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    76
    ph ->Type       = Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    77
    ph ->Implements = Type;   // By default, no clue on what is implementing
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    78
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    79
    ph ->InputChannels  = InputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    80
    ph ->OutputChannels = OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    81
    ph ->EvalPtr        = EvalPtr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    82
    ph ->DupElemPtr     = DupElemPtr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    83
    ph ->FreePtr        = FreePtr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    84
    ph ->Data           = Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    85
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    86
    return ph;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    87
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    88
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    90
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    91
void EvaluateIdentity(const cmsFloat32Number In[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    92
                            cmsFloat32Number Out[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    93
                      const cmsStage *mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    94
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    95
    memmove(Out, In, mpe ->InputChannels * sizeof(cmsFloat32Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    96
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    97
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    98
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
    99
cmsStage* CMSEXPORT cmsStageAllocIdentity(cmsContext ContextID, cmsUInt32Number nChannels)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   100
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   101
    return _cmsStageAllocPlaceholder(ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   102
                                   cmsSigIdentityElemType,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   103
                                   nChannels, nChannels,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   104
                                   EvaluateIdentity,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   105
                                   NULL,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   106
                                   NULL,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   107
                                   NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   108
 }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   110
// Conversion functions. From floating point to 16 bits
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   111
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   112
void FromFloatTo16(const cmsFloat32Number In[], cmsUInt16Number Out[], cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   113
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   114
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   115
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   116
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   117
        Out[i] = _cmsQuickSaturateWord(In[i] * 65535.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   118
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   119
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   120
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   121
// From 16 bits to floating point
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   122
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   123
void From16ToFloat(const cmsUInt16Number In[], cmsFloat32Number Out[], cmsUInt32Number n)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   124
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   125
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   126
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   127
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   128
        Out[i] = (cmsFloat32Number) In[i] / 65535.0F;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   129
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   130
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   133
// This function is quite useful to analyze the structure of a LUT and retrieve the MPE elements
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   134
// that conform the LUT. It should be called with the LUT, the number of expected elements and
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   135
// then a list of expected types followed with a list of cmsFloat64Number pointers to MPE elements. If
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   136
// the function founds a match with current pipeline, it fills the pointers and returns TRUE
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   137
// if not, returns FALSE without touching anything. Setting pointers to NULL does bypass
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   138
// the storage process.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   139
cmsBool  CMSEXPORT cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, cmsUInt32Number n, ...)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   140
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   141
    va_list args;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   142
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   143
    cmsStage* mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   144
    cmsStageSignature Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   145
    void** ElemPtr;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   146
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   147
    // Make sure same number of elements
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   148
    if (cmsPipelineStageCount(Lut) != n) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   149
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   150
    va_start(args, n);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   152
    // Iterate across asked types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   153
    mpe = Lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   154
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   155
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   156
        // Get asked type
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   157
        Type  = (cmsStageSignature)va_arg(args, cmsStageSignature);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   158
        if (mpe ->Type != Type) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   159
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   160
            va_end(args);       // Mismatch. We are done.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   161
            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   162
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   163
        mpe = mpe ->Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   164
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   165
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   166
    // Found a combination, fill pointers if not NULL
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   167
    mpe = Lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   168
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   169
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   170
        ElemPtr = va_arg(args, void**);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   171
        if (ElemPtr != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   172
            *ElemPtr = mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   173
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   174
        mpe = mpe ->Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   175
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   177
    va_end(args);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   178
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   179
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   180
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   181
// Below there are implementations for several types of elements. Each type may be implemented by a
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   182
// evaluation function, a duplication function, a function to free resources and a constructor.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   183
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   184
// *************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   185
// Type cmsSigCurveSetElemType (curves)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   186
// *************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   187
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   188
cmsToneCurve** _cmsStageGetPtrToCurveSet(const cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   189
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   190
    _cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   191
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   192
    return Data ->TheCurves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   193
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   195
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   196
void EvaluateCurves(const cmsFloat32Number In[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   197
                    cmsFloat32Number Out[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   198
                    const cmsStage *mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   199
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   200
    _cmsStageToneCurvesData* Data;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   201
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   202
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   203
    _cmsAssert(mpe != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   204
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   205
    Data = (_cmsStageToneCurvesData*) mpe ->Data;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   206
    if (Data == NULL) return;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   207
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   208
    if (Data ->TheCurves == NULL) return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   209
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   210
    for (i=0; i < Data ->nCurves; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   211
        Out[i] = cmsEvalToneCurveFloat(Data ->TheCurves[i], In[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   212
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   213
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   214
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   215
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   216
void CurveSetElemTypeFree(cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   217
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   218
    _cmsStageToneCurvesData* Data;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   219
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   220
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   221
    _cmsAssert(mpe != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   222
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   223
    Data = (_cmsStageToneCurvesData*) mpe ->Data;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   224
    if (Data == NULL) return;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   225
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   226
    if (Data ->TheCurves != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   227
        for (i=0; i < Data ->nCurves; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   228
            if (Data ->TheCurves[i] != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   229
                cmsFreeToneCurve(Data ->TheCurves[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   230
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   231
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   232
    _cmsFree(mpe ->ContextID, Data ->TheCurves);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   233
    _cmsFree(mpe ->ContextID, Data);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   236
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   237
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   238
void* CurveSetDup(cmsStage* mpe)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   240
    _cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   241
    _cmsStageToneCurvesData* NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   242
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   243
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   244
    NewElem = (_cmsStageToneCurvesData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageToneCurvesData));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   245
    if (NewElem == NULL) return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   247
    NewElem ->nCurves   = Data ->nCurves;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   248
    NewElem ->TheCurves = (cmsToneCurve**) _cmsCalloc(mpe ->ContextID, NewElem ->nCurves, sizeof(cmsToneCurve*));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   249
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   250
    if (NewElem ->TheCurves == NULL) goto Error;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   252
    for (i=0; i < NewElem ->nCurves; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   253
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   254
        // Duplicate each curve. It may fail.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   255
        NewElem ->TheCurves[i] = cmsDupToneCurve(Data ->TheCurves[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   256
        if (NewElem ->TheCurves[i] == NULL) goto Error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   257
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   259
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   260
    return (void*) NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   261
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   262
Error:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   264
    if (NewElem ->TheCurves != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   265
        for (i=0; i < NewElem ->nCurves; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   266
            if (NewElem ->TheCurves[i])
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   267
                cmsFreeToneCurve(Data ->TheCurves[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   268
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   269
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   270
    _cmsFree(mpe ->ContextID, Data ->TheCurves);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   271
    _cmsFree(mpe ->ContextID, NewElem);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   272
    return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   273
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   275
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   276
// Curves == NULL forces identity curves
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   277
cmsStage* CMSEXPORT cmsStageAllocToneCurves(cmsContext ContextID, cmsUInt32Number nChannels, cmsToneCurve* const Curves[])
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   278
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   279
    cmsUInt32Number i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   280
    _cmsStageToneCurvesData* NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   281
    cmsStage* NewMPE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   284
    NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCurveSetElemType, nChannels, nChannels,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   285
                                     EvaluateCurves, CurveSetDup, CurveSetElemTypeFree, NULL );
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   286
    if (NewMPE == NULL) return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   288
    NewElem = (_cmsStageToneCurvesData*) _cmsMallocZero(ContextID, sizeof(_cmsStageToneCurvesData));
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   289
    if (NewElem == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   290
        cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   291
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   292
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   293
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   294
    NewMPE ->Data  = (void*) NewElem;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   295
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   296
    NewElem ->nCurves   = nChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   297
    NewElem ->TheCurves = (cmsToneCurve**) _cmsCalloc(ContextID, nChannels, sizeof(cmsToneCurve*));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   298
    if (NewElem ->TheCurves == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   299
        cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   300
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   301
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   302
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   303
    for (i=0; i < nChannels; i++) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   305
        if (Curves == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   306
            NewElem ->TheCurves[i] = cmsBuildGamma(ContextID, 1.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   307
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   308
        else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   309
            NewElem ->TheCurves[i] = cmsDupToneCurve(Curves[i]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   310
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   311
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   312
        if (NewElem ->TheCurves[i] == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   313
            cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   314
            return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   315
        }
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   316
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   317
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   318
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   319
   return NewMPE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   320
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   321
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   322
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   323
// Create a bunch of identity curves
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   324
cmsStage* _cmsStageAllocIdentityCurves(cmsContext ContextID, int nChannels)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   325
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   326
    cmsStage* mpe = cmsStageAllocToneCurves(ContextID, nChannels, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   327
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   328
    if (mpe == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   329
    mpe ->Implements = cmsSigIdentityElemType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   330
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   331
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   332
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   334
// *************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   335
// Type cmsSigMatrixElemType (Matrices)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   336
// *************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   337
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   338
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   339
// Special care should be taken here because precision loss. A temporary cmsFloat64Number buffer is being used
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   340
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   341
void EvaluateMatrix(const cmsFloat32Number In[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   342
                    cmsFloat32Number Out[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   343
                    const cmsStage *mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   344
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   345
    cmsUInt32Number i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   346
    _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   347
    cmsFloat64Number Tmp;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   348
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   349
    // Input is already in 0..1.0 notation
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   350
    for (i=0; i < mpe ->OutputChannels; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   351
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   352
        Tmp = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   353
        for (j=0; j < mpe->InputChannels; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   354
            Tmp += In[j] * Data->Double[i*mpe->InputChannels + j];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   355
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   356
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   357
        if (Data ->Offset != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   358
            Tmp += Data->Offset[i];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   360
        Out[i] = (cmsFloat32Number) Tmp;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   361
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   362
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   363
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   364
    // Output in 0..1.0 domain
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   365
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   366
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   368
// Duplicate a yet-existing matrix element
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   369
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   370
void* MatrixElemDup(cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   371
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   372
    _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   373
    _cmsStageMatrixData* NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   374
    cmsUInt32Number sz;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   376
    NewElem = (_cmsStageMatrixData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageMatrixData));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   377
    if (NewElem == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   378
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   379
    sz = mpe ->InputChannels * mpe ->OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   380
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   381
    NewElem ->Double = (cmsFloat64Number*) _cmsDupMem(mpe ->ContextID, Data ->Double, sz * sizeof(cmsFloat64Number)) ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   382
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   383
    if (Data ->Offset)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   384
        NewElem ->Offset = (cmsFloat64Number*) _cmsDupMem(mpe ->ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   385
                                                Data ->Offset, mpe -> OutputChannels * sizeof(cmsFloat64Number)) ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   386
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   387
    return (void*) NewElem;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
static
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   392
void MatrixElemTypeFree(cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   393
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   394
    _cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   395
    if (Data ->Double)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   396
        _cmsFree(mpe ->ContextID, Data ->Double);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   397
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   398
    if (Data ->Offset)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   399
        _cmsFree(mpe ->ContextID, Data ->Offset);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   400
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   401
    _cmsFree(mpe ->ContextID, mpe ->Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   402
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   403
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   404
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   405
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   406
cmsStage*  CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number Rows, cmsUInt32Number Cols,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   407
                                     const cmsFloat64Number* Matrix, const cmsFloat64Number* Offset)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   409
    cmsUInt32Number i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   410
    _cmsStageMatrixData* NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   411
    cmsStage* NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   412
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   413
    n = Rows * Cols;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   414
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   415
    // Check for overflow
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   416
    if (n == 0) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   417
    if (n >= UINT_MAX / Cols) return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   418
    if (n >= UINT_MAX / Rows) return NULL;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   419
    if (n < Rows || n < Cols) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   420
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   421
    NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigMatrixElemType, Cols, Rows,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   422
                                     EvaluateMatrix, MatrixElemDup, MatrixElemTypeFree, NULL );
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   423
    if (NewMPE == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   424
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   425
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   426
    NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageMatrixData));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   427
    if (NewElem == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   428
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   429
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   430
    NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat64Number));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   432
    if (NewElem->Double == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   433
        MatrixElemTypeFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   434
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   435
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   436
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   437
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   438
        NewElem ->Double[i] = Matrix[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   439
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   440
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   441
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   442
    if (Offset != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   443
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   444
        NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Cols, sizeof(cmsFloat64Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   445
        if (NewElem->Offset == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   446
           MatrixElemTypeFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   447
           return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   448
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   449
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   450
        for (i=0; i < Cols; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   451
                NewElem ->Offset[i] = Offset[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   452
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   453
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   454
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   455
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   456
    NewMPE ->Data  = (void*) NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   457
    return NewMPE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   461
// *************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   462
// Type cmsSigCLutElemType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   463
// *************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   464
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   465
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   466
// Evaluate in true floating point
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   467
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   468
void EvaluateCLUTfloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   470
    _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   471
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   472
    Data -> Params ->Interpolation.LerpFloat(In, Out, Data->Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   473
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   474
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   476
// Convert to 16 bits, evaluate, and back to floating point
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   477
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   478
void EvaluateCLUTfloatIn16(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   479
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   480
    _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   481
    cmsUInt16Number In16[MAX_STAGE_CHANNELS], Out16[MAX_STAGE_CHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   483
    _cmsAssert(mpe ->InputChannels  <= MAX_STAGE_CHANNELS);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   484
    _cmsAssert(mpe ->OutputChannels <= MAX_STAGE_CHANNELS);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   485
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   486
    FromFloatTo16(In, In16, mpe ->InputChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   487
    Data -> Params ->Interpolation.Lerp16(In16, Out16, Data->Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   488
    From16ToFloat(Out16, Out,  mpe ->OutputChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   489
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   490
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   492
// Given an hypercube of b dimensions, with Dims[] number of nodes by dimension, calculate the total amount of nodes
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   493
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   494
cmsUInt32Number CubeSize(const cmsUInt32Number Dims[], cmsUInt32Number b)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   495
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   496
    cmsUInt32Number rv, dim;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   497
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   498
    _cmsAssert(Dims != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   499
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   500
    for (rv = 1; b > 0; b--) {
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   501
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   502
        dim = Dims[b-1];
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   503
        if (dim == 0) return 0;  // Error
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   504
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   505
        rv *= dim;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   506
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   507
        // Check for overflow
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   508
        if (rv > UINT_MAX / dim) return 0;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   509
    }
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   510
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   511
    return rv;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   512
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   513
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   514
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   515
void* CLUTElemDup(cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   516
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   517
    _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   518
    _cmsStageCLutData* NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   519
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   521
    NewElem = (_cmsStageCLutData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageCLutData));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   522
    if (NewElem == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   523
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   524
    NewElem ->nEntries       = Data ->nEntries;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   525
    NewElem ->HasFloatValues = Data ->HasFloatValues;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   526
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   527
    if (Data ->Tab.T) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   529
        if (Data ->HasFloatValues)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   530
            NewElem ->Tab.TFloat = (cmsFloat32Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.TFloat, Data ->nEntries * sizeof (cmsFloat32Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   531
        else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   532
            NewElem ->Tab.T = (cmsUInt16Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.T, Data ->nEntries * sizeof (cmsUInt16Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   533
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   535
    NewElem ->Params   = _cmsComputeInterpParamsEx(mpe ->ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   536
                                                   Data ->Params ->nSamples,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   537
                                                   Data ->Params ->nInputs,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   538
                                                   Data ->Params ->nOutputs,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   539
                                                   NewElem ->Tab.T,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   540
                                                   Data ->Params ->dwFlags);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   541
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   542
    return (void*) NewElem;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
static
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   547
void CLutElemTypeFree(cmsStage* mpe)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   549
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   550
    _cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   551
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   552
    // Already empty
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   553
    if (Data == NULL) return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   554
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   555
    // This works for both types
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   556
    if (Data -> Tab.T)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   557
        _cmsFree(mpe ->ContextID, Data -> Tab.T);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   558
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   559
    _cmsFreeInterpParams(Data ->Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   560
    _cmsFree(mpe ->ContextID, mpe ->Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   561
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   562
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   563
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   564
// Allocates a 16-bit multidimensional CLUT. This is evaluated at 16-bit precision. Table may have different
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   565
// granularity on each dimension.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   566
cmsStage* CMSEXPORT cmsStageAllocCLut16bitGranular(cmsContext ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   567
                                         const cmsUInt32Number clutPoints[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   568
                                         cmsUInt32Number inputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   569
                                         cmsUInt32Number outputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   570
                                         const cmsUInt16Number* Table)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   571
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   572
    cmsUInt32Number i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   573
    _cmsStageCLutData* NewElem;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   574
    cmsStage* NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   575
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   576
    _cmsAssert(clutPoints != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   577
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   578
    if (inputChan > MAX_INPUT_DIMENSIONS) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   579
        cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", inputChan, MAX_INPUT_DIMENSIONS);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   580
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   581
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   582
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   583
    NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCLutElemType, inputChan, outputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   584
                                     EvaluateCLUTfloatIn16, CLUTElemDup, CLutElemTypeFree, NULL );
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   585
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   586
    if (NewMPE == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   587
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   588
    NewElem = (_cmsStageCLutData*) _cmsMallocZero(ContextID, sizeof(_cmsStageCLutData));
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   589
    if (NewElem == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   590
        cmsStageFree(NewMPE);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   591
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   592
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   593
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   594
    NewMPE ->Data  = (void*) NewElem;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   595
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   596
    NewElem -> nEntries = n = outputChan * CubeSize(clutPoints, inputChan);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   597
    NewElem -> HasFloatValues = FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   598
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   599
    if (n == 0) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   600
        cmsStageFree(NewMPE);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   601
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   602
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   603
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   604
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   605
    NewElem ->Tab.T  = (cmsUInt16Number*) _cmsCalloc(ContextID, n, sizeof(cmsUInt16Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   606
    if (NewElem ->Tab.T == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   607
        cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   608
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   609
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   611
    if (Table != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   612
        for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   613
            NewElem ->Tab.T[i] = Table[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   614
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   615
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   616
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   617
    NewElem ->Params = _cmsComputeInterpParamsEx(ContextID, clutPoints, inputChan, outputChan, NewElem ->Tab.T, CMS_LERP_FLAGS_16BITS);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   618
    if (NewElem ->Params == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   619
        cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   620
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   621
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   622
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   623
    return NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   624
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   626
cmsStage* CMSEXPORT cmsStageAllocCLut16bit(cmsContext ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   627
                                    cmsUInt32Number nGridPoints,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   628
                                    cmsUInt32Number inputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   629
                                    cmsUInt32Number outputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   630
                                    const cmsUInt16Number* Table)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   631
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   632
    cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   633
    int i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   634
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   635
   // Our resulting LUT would be same gridpoints on all dimensions
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   636
    for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   637
        Dimensions[i] = nGridPoints;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   638
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   639
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   640
    return cmsStageAllocCLut16bitGranular(ContextID, Dimensions, inputChan, outputChan, Table);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   641
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   642
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   643
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   644
cmsStage* CMSEXPORT cmsStageAllocCLutFloat(cmsContext ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   645
                                       cmsUInt32Number nGridPoints,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   646
                                       cmsUInt32Number inputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   647
                                       cmsUInt32Number outputChan,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   648
                                       const cmsFloat32Number* Table)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   649
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   650
   cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   651
   int i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   652
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   653
    // Our resulting LUT would be same gridpoints on all dimensions
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   654
    for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   655
        Dimensions[i] = nGridPoints;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   656
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   657
    return cmsStageAllocCLutFloatGranular(ContextID, Dimensions, inputChan, outputChan, Table);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   661
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   662
cmsStage* CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table)
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   663
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   664
    cmsUInt32Number i, n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   665
    _cmsStageCLutData* NewElem;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   666
    cmsStage* NewMPE;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   667
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   668
    _cmsAssert(clutPoints != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   669
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   670
    if (inputChan > MAX_INPUT_DIMENSIONS) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   671
        cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", inputChan, MAX_INPUT_DIMENSIONS);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   672
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   673
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   674
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   675
    NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCLutElemType, inputChan, outputChan,
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   676
                                             EvaluateCLUTfloat, CLUTElemDup, CLutElemTypeFree, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   677
    if (NewMPE == NULL) return NULL;
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   678
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   679
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   680
    NewElem = (_cmsStageCLutData*) _cmsMallocZero(ContextID, sizeof(_cmsStageCLutData));
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   681
    if (NewElem == NULL) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   682
        cmsStageFree(NewMPE);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   683
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   684
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   685
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   686
    NewMPE ->Data  = (void*) NewElem;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   687
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   688
    // There is a potential integer overflow on conputing n and nEntries.
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   689
    NewElem -> nEntries = n = outputChan * CubeSize(clutPoints, inputChan);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   690
    NewElem -> HasFloatValues = TRUE;
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   691
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   692
    if (n == 0) {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   693
        cmsStageFree(NewMPE);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   694
        return NULL;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   695
    }
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   696
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   697
    NewElem ->Tab.TFloat  = (cmsFloat32Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat32Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   698
    if (NewElem ->Tab.TFloat == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   699
        cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   700
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   701
    }
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   702
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   703
    if (Table != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   704
        for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   705
            NewElem ->Tab.TFloat[i] = Table[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   706
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   707
    }
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   708
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   709
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   710
    NewElem ->Params = _cmsComputeInterpParamsEx(ContextID, clutPoints,  inputChan, outputChan, NewElem ->Tab.TFloat, CMS_LERP_FLAGS_FLOAT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   711
    if (NewElem ->Params == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   712
        cmsStageFree(NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   713
        return NULL;
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   714
    }
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   715
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   716
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   717
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   718
    return NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   719
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   720
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   721
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   722
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   723
int IdentitySampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void * Cargo)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   724
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   725
    int nChan = *(int*) Cargo;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   726
    int i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   727
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   728
    for (i=0; i < nChan; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   729
        Out[i] = In[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   730
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   731
    return 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   732
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   733
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   734
// Creates an MPE that just copies input to output
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   735
cmsStage* _cmsStageAllocIdentityCLut(cmsContext ContextID, int nChan)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   736
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   737
    cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   738
    cmsStage* mpe ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   739
    int i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   740
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   741
    for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   742
        Dimensions[i] = 2;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   743
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   744
    mpe = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, nChan, nChan, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   745
    if (mpe == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   746
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   747
    if (!cmsStageSampleCLut16bit(mpe, IdentitySampler, &nChan, 0)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   748
        cmsStageFree(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   749
        return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   750
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   751
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   752
    mpe ->Implements = cmsSigIdentityElemType;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   753
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   754
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   755
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   756
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   757
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   758
// Quantize a value 0 <= i < MaxSamples to 0..0xffff
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   759
cmsUInt16Number _cmsQuantizeVal(cmsFloat64Number i, int MaxSamples)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   760
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   761
    cmsFloat64Number x;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   762
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   763
    x = ((cmsFloat64Number) i * 65535.) / (cmsFloat64Number) (MaxSamples - 1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   764
    return _cmsQuickSaturateWord(x);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   765
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   766
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   767
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   768
// This routine does a sweep on whole input space, and calls its callback
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   769
// function on knots. returns TRUE if all ok, FALSE otherwise.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   770
cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, void * Cargo, cmsUInt32Number dwFlags)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   771
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   772
    int i, t, nTotalPoints, index, rest;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   773
    int nInputs, nOutputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   774
    cmsUInt32Number* nSamples;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   775
    cmsUInt16Number In[cmsMAXCHANNELS], Out[MAX_STAGE_CHANNELS];
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   776
    _cmsStageCLutData* clut;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   777
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   778
    if (mpe == NULL) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   779
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   780
    clut = (_cmsStageCLutData*) mpe->Data;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   781
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   782
    if (clut == NULL) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   783
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   784
    nSamples = clut->Params ->nSamples;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   785
    nInputs  = clut->Params ->nInputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   786
    nOutputs = clut->Params ->nOutputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   787
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   788
    if (nInputs >= cmsMAXCHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   789
    if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   790
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   791
    nTotalPoints = CubeSize(nSamples, nInputs);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   792
    if (nTotalPoints == 0) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   793
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   794
    index = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   795
    for (i = 0; i < nTotalPoints; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   796
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   797
        rest = i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   798
        for (t = nInputs-1; t >=0; --t) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   799
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   800
            cmsUInt32Number  Colorant = rest % nSamples[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   801
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   802
            rest /= nSamples[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   803
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   804
            In[t] = _cmsQuantizeVal(Colorant, nSamples[t]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   805
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   806
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   807
        if (clut ->Tab.T != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   808
            for (t=0; t < nOutputs; t++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   809
                Out[t] = clut->Tab.T[index + t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   810
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   811
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   812
        if (!Sampler(In, Out, Cargo))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   813
            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   814
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   815
        if (!(dwFlags & SAMPLER_INSPECT)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   816
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   817
            if (clut ->Tab.T != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   818
                for (t=0; t < nOutputs; t++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   819
                    clut->Tab.T[index + t] = Out[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   820
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   821
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   822
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   823
        index += nOutputs;
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   824
    }
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   825
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   826
    return TRUE;
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   827
}
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   828
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   829
// Same as anterior, but for floting point
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   830
cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler, void * Cargo, cmsUInt32Number dwFlags)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   832
    int i, t, nTotalPoints, index, rest;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   833
    int nInputs, nOutputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   834
    cmsUInt32Number* nSamples;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   835
    cmsFloat32Number In[cmsMAXCHANNELS], Out[MAX_STAGE_CHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   836
    _cmsStageCLutData* clut = (_cmsStageCLutData*) mpe->Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   837
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   838
    nSamples = clut->Params ->nSamples;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   839
    nInputs  = clut->Params ->nInputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   840
    nOutputs = clut->Params ->nOutputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   841
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   842
    if (nInputs >= cmsMAXCHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   843
    if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   844
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   845
    nTotalPoints = CubeSize(nSamples, nInputs);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   846
    if (nTotalPoints == 0) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   847
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   848
    index = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   849
    for (i = 0; i < nTotalPoints; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   850
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   851
        rest = i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   852
        for (t = nInputs-1; t >=0; --t) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   853
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   854
            cmsUInt32Number  Colorant = rest % nSamples[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   855
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   856
            rest /= nSamples[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   857
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   858
            In[t] =  (cmsFloat32Number) (_cmsQuantizeVal(Colorant, nSamples[t]) / 65535.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   859
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   860
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   861
        if (clut ->Tab.TFloat != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   862
            for (t=0; t < nOutputs; t++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   863
                Out[t] = clut->Tab.TFloat[index + t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   864
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   866
        if (!Sampler(In, Out, Cargo))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   867
            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   868
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   869
        if (!(dwFlags & SAMPLER_INSPECT)) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   870
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   871
            if (clut ->Tab.TFloat != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   872
                for (t=0; t < nOutputs; t++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   873
                    clut->Tab.TFloat[index + t] = Out[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   874
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   875
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   876
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   877
        index += nOutputs;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   878
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   879
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   880
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   881
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   882
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   883
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   884
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   885
// This routine does a sweep on whole input space, and calls its callback
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   886
// function on knots. returns TRUE if all ok, FALSE otherwise.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   887
cmsBool CMSEXPORT cmsSliceSpace16(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   888
                                         cmsSAMPLER16 Sampler, void * Cargo)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   889
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   890
    int i, t, nTotalPoints, rest;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   891
    cmsUInt16Number In[cmsMAXCHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   892
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   893
    if (nInputs >= cmsMAXCHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   894
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   895
    nTotalPoints = CubeSize(clutPoints, nInputs);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   896
    if (nTotalPoints == 0) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   897
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   898
    for (i = 0; i < nTotalPoints; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   899
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   900
        rest = i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   901
        for (t = nInputs-1; t >=0; --t) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   903
            cmsUInt32Number  Colorant = rest % clutPoints[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   904
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   905
            rest /= clutPoints[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   906
            In[t] = _cmsQuantizeVal(Colorant, clutPoints[t]);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   907
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   908
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   909
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   910
        if (!Sampler(In, NULL, Cargo))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   911
            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   912
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   913
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   914
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   915
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   917
cmsInt32Number CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   918
                                            cmsSAMPLERFLOAT Sampler, void * Cargo)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   919
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   920
    int i, t, nTotalPoints, rest;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   921
    cmsFloat32Number In[cmsMAXCHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   922
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   923
    if (nInputs >= cmsMAXCHANNELS) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   924
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   925
    nTotalPoints = CubeSize(clutPoints, nInputs);
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
   926
    if (nTotalPoints == 0) return FALSE;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   927
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   928
    for (i = 0; i < nTotalPoints; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   929
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   930
        rest = i;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   931
        for (t = nInputs-1; t >=0; --t) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   932
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   933
            cmsUInt32Number  Colorant = rest % clutPoints[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   934
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   935
            rest /= clutPoints[t];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   936
            In[t] =  (cmsFloat32Number) (_cmsQuantizeVal(Colorant, clutPoints[t]) / 65535.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   937
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   938
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   940
        if (!Sampler(In, NULL, Cargo))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   941
            return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   942
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   943
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   944
    return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   945
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   946
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   947
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   948
// Type cmsSigLab2XYZElemType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   949
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   950
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
   951
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   952
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   953
void EvaluateLab2XYZ(const cmsFloat32Number In[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   954
                     cmsFloat32Number Out[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   955
                     const cmsStage *mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   956
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   957
    cmsCIELab Lab;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   958
    cmsCIEXYZ XYZ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   959
    const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   960
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   961
    // V4 rules
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   962
    Lab.L = In[0] * 100.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   963
    Lab.a = In[1] * 255.0 - 128.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   964
    Lab.b = In[2] * 255.0 - 128.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   965
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   966
    cmsLab2XYZ(NULL, &XYZ, &Lab);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   967
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   968
    // From XYZ, range 0..19997 to 0..1.0, note that 1.99997 comes from 0xffff
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   969
    // encoded as 1.15 fixed point, so 1 + (32767.0 / 32768.0)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   970
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   971
    Out[0] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.X / XYZadj);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   972
    Out[1] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.Y / XYZadj);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   973
    Out[2] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.Z / XYZadj);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   974
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   975
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   976
    cmsUNUSED_PARAMETER(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   977
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   980
// No dup or free routines needed, as the structure has no pointers in it.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   981
cmsStage* _cmsStageAllocLab2XYZ(cmsContext ContextID)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   982
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   983
    return _cmsStageAllocPlaceholder(ContextID, cmsSigLab2XYZElemType, 3, 3, EvaluateLab2XYZ, NULL, NULL, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   984
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   985
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   986
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   987
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   988
// v2 L=100 is supposed to be placed on 0xFF00. There is no reasonable
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   989
// number of gridpoints that would make exact match. However, a prelinearization
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   990
// of 258 entries, would map 0xFF00 exactly on entry 257, and this is good to avoid scum dot.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   991
// Almost all what we need but unfortunately, the rest of entries should be scaled by
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   992
// (255*257/256) and this is not exact.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   993
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   994
cmsStage* _cmsStageAllocLabV2ToV4curves(cmsContext ContextID)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   995
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   996
    cmsStage* mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   997
    cmsToneCurve* LabTable[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   998
    int i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
   999
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1000
    LabTable[0] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1001
    LabTable[1] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1002
    LabTable[2] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1003
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1004
    for (j=0; j < 3; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1005
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1006
        if (LabTable[j] == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1007
            cmsFreeToneCurveTriple(LabTable);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1008
            return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1009
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1010
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1011
        // We need to map * (0xffff / 0xff00), thats same as (257 / 256)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1012
        // So we can use 258-entry tables to do the trick (i / 257) * (255 * 257) * (257 / 256);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1013
        for (i=0; i < 257; i++)  {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1014
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1015
            LabTable[j]->Table16[i] = (cmsUInt16Number) ((i * 0xffff + 0x80) >> 8);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1016
        }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1017
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1018
        LabTable[j] ->Table16[257] = 0xffff;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1019
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1020
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1021
    mpe = cmsStageAllocToneCurves(ContextID, 3, LabTable);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1022
    cmsFreeToneCurveTriple(LabTable);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1023
18210
662eb8b3dfb5 8007925: Improve cmsStageAllocLabV2ToV4curves
jgodinez
parents: 14300
diff changeset
  1024
    if (mpe == NULL) return mpe;
17671
bb08d5e5bd5e 8003444: Fix potential NULL pointer dereference
jchen
parents: 14300
diff changeset
  1025
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1026
    mpe ->Implements = cmsSigLabV2toV4;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1027
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1028
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1029
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1030
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1031
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1032
// Matrix-based conversion, which is more accurate, but slower and cannot properly be saved in devicelink profiles
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1033
cmsStage* _cmsStageAllocLabV2ToV4(cmsContext ContextID)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1034
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1035
    static const cmsFloat64Number V2ToV4[] = { 65535.0/65280.0, 0, 0,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1036
                                     0, 65535.0/65280.0, 0,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1037
                                     0, 0, 65535.0/65280.0
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1038
                                     };
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1039
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1040
    cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, V2ToV4, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1041
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1042
    if (mpe == NULL) return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1043
    mpe ->Implements = cmsSigLabV2toV4;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1044
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1045
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1046
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1047
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1048
// Reverse direction
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1049
cmsStage* _cmsStageAllocLabV4ToV2(cmsContext ContextID)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1050
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1051
    static const cmsFloat64Number V4ToV2[] = { 65280.0/65535.0, 0, 0,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1052
                                     0, 65280.0/65535.0, 0,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1053
                                     0, 0, 65280.0/65535.0
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1054
                                     };
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1055
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1056
     cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, V4ToV2, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1057
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1058
    if (mpe == NULL) return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1059
    mpe ->Implements = cmsSigLabV4toV2;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1060
    return mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1061
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1062
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1063
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1064
// To Lab to float. Note that the MPE gives numbers in normal Lab range
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1065
// and we need 0..1.0 range for the formatters
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1066
// L* : 0...100 => 0...1.0  (L* / 100)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1067
// ab* : -128..+127 to 0..1  ((ab* + 128) / 255)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1068
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1069
cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1070
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1071
    static const cmsFloat64Number a1[] = {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1072
        1.0/100.0, 0, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1073
        0, 1.0/255.0, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1074
        0, 0, 1.0/255.0
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1075
    };
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1076
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1077
    static const cmsFloat64Number o1[] = {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1078
        0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1079
        128.0/255.0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1080
        128.0/255.0
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1081
    };
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1082
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1083
    cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, o1);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1084
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1085
    if (mpe == NULL) return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1086
    mpe ->Implements = cmsSigLab2FloatPCS;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1087
    return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1088
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1089
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1090
// Fom XYZ to floating point PCS
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1091
cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1092
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1093
#define n (32768.0/65535.0)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1094
    static const cmsFloat64Number a1[] = {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1095
        n, 0, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1096
        0, n, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1097
        0, 0, n
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1098
    };
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1099
#undef n
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1100
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1101
    cmsStage *mpe =  cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1102
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1103
    if (mpe == NULL) return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1104
    mpe ->Implements = cmsSigXYZ2FloatPCS;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1105
    return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1106
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1107
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1108
cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1109
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1110
    static const cmsFloat64Number a1[] = {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1111
        100.0, 0, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1112
        0, 255.0, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1113
        0, 0, 255.0
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1114
    };
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1115
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1116
    static const cmsFloat64Number o1[] = {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1117
        0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1118
        -128.0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1119
        -128.0
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1120
    };
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1121
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1122
    cmsStage *mpe =  cmsStageAllocMatrix(ContextID, 3, 3, a1, o1);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1123
    if (mpe == NULL) return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1124
    mpe ->Implements = cmsSigFloatPCS2Lab;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1125
    return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1126
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1127
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1128
cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1129
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1130
#define n (65535.0/32768.0)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1131
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1132
    static const cmsFloat64Number a1[] = {
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1133
        n, 0, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1134
        0, n, 0,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1135
        0, 0, n
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1136
    };
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1137
#undef n
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1138
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1139
    cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1140
    if (mpe == NULL) return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1141
    mpe ->Implements = cmsSigFloatPCS2XYZ;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1142
    return mpe;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1143
}
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1144
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1145
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1146
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1147
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1148
// Type cmsSigXYZ2LabElemType
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1149
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1150
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1151
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1152
void EvaluateXYZ2Lab(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1153
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1154
    cmsCIELab Lab;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1155
    cmsCIEXYZ XYZ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1156
    const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1157
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1158
    // From 0..1.0 to XYZ
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1159
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1160
    XYZ.X = In[0] * XYZadj;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1161
    XYZ.Y = In[1] * XYZadj;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1162
    XYZ.Z = In[2] * XYZadj;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1163
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1164
    cmsXYZ2Lab(NULL, &Lab, &XYZ);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1165
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1166
    // From V4 Lab to 0..1.0
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1167
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1168
    Out[0] = (cmsFloat32Number) (Lab.L / 100.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1169
    Out[1] = (cmsFloat32Number) ((Lab.a + 128.0) / 255.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1170
    Out[2] = (cmsFloat32Number) ((Lab.b + 128.0) / 255.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1171
    return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1172
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1173
    cmsUNUSED_PARAMETER(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1174
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1175
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1176
cmsStage* _cmsStageAllocXYZ2Lab(cmsContext ContextID)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1177
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1178
    return _cmsStageAllocPlaceholder(ContextID, cmsSigXYZ2LabElemType, 3, 3, EvaluateXYZ2Lab, NULL, NULL, NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1179
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1180
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1181
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1182
// ********************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1183
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1184
// For v4, S-Shaped curves are placed in a/b axis to increase resolution near gray
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1185
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1186
cmsStage* _cmsStageAllocLabPrelin(cmsContext ContextID)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1187
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1188
    cmsToneCurve* LabTable[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1189
    cmsFloat64Number Params[1] =  {2.4} ;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1190
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1191
    LabTable[0] = cmsBuildGamma(ContextID, 1.0);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1192
    LabTable[1] = cmsBuildParametricToneCurve(ContextID, 108, Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1193
    LabTable[2] = cmsBuildParametricToneCurve(ContextID, 108, Params);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1194
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1195
    return cmsStageAllocToneCurves(ContextID, 3, LabTable);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1196
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1198
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1199
// Free a single MPE
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1200
void CMSEXPORT cmsStageFree(cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1201
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1202
    if (mpe ->FreePtr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1203
        mpe ->FreePtr(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1204
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1205
    _cmsFree(mpe ->ContextID, mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1206
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1207
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1208
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1209
cmsUInt32Number  CMSEXPORT cmsStageInputChannels(const cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1210
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1211
    return mpe ->InputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1212
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1213
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1214
cmsUInt32Number  CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1215
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1216
    return mpe ->OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1217
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1218
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1219
cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1220
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1221
    return mpe -> Type;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1222
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1223
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1224
void* CMSEXPORT cmsStageData(const cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1225
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1226
    return mpe -> Data;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1227
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1228
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1229
cmsStage*  CMSEXPORT cmsStageNext(const cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1230
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1231
    return mpe -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1232
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1233
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1234
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1235
// Duplicates an MPE
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1236
cmsStage* CMSEXPORT cmsStageDup(cmsStage* mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1237
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1238
    cmsStage* NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1239
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1240
    if (mpe == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1241
    NewMPE = _cmsStageAllocPlaceholder(mpe ->ContextID,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1242
                                     mpe ->Type,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1243
                                     mpe ->InputChannels,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1244
                                     mpe ->OutputChannels,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1245
                                     mpe ->EvalPtr,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1246
                                     mpe ->DupElemPtr,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1247
                                     mpe ->FreePtr,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1248
                                     NULL);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1249
    if (NewMPE == NULL) return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1250
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1251
    NewMPE ->Implements     = mpe ->Implements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1252
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1253
    if (mpe ->DupElemPtr)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1254
        NewMPE ->Data       = mpe ->DupElemPtr(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1255
    else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1256
        NewMPE ->Data       = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1257
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1258
    return NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1259
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1260
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1261
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1262
// ***********************************************************************************************************
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1263
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1264
// This function sets up the channel count
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1265
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1266
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1267
void BlessLUT(cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1268
{
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 18253
diff changeset
  1269
    // We can set the input/output channels only if we have elements.
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1270
    if (lut ->Elements != NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1271
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1272
        cmsStage *First, *Last;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1273
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1274
        First  = cmsPipelineGetPtrToFirstStage(lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1275
        Last   = cmsPipelineGetPtrToLastStage(lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1276
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1277
        if (First != NULL)lut ->InputChannels = First ->InputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1278
        if (Last != NULL) lut ->OutputChannels = Last ->OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1279
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1280
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1281
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1282
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1283
// Default to evaluate the LUT on 16 bit-basis. Precision is retained.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1284
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1285
void _LUTeval16(register const cmsUInt16Number In[], register cmsUInt16Number Out[],  register const void* D)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1286
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1287
    cmsPipeline* lut = (cmsPipeline*) D;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1288
    cmsStage *mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1289
    cmsFloat32Number Storage[2][MAX_STAGE_CHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1290
    int Phase = 0, NextPhase;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1291
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1292
    From16ToFloat(In, &Storage[Phase][0], lut ->InputChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1293
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1294
    for (mpe = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1295
         mpe != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1296
         mpe = mpe ->Next) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1297
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1298
             NextPhase = Phase ^ 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1299
             mpe ->EvalPtr(&Storage[Phase][0], &Storage[NextPhase][0], mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1300
             Phase = NextPhase;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1301
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1302
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1303
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1304
    FromFloatTo16(&Storage[Phase][0], Out, lut ->OutputChannels);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1305
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1306
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1307
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1308
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1309
// Does evaluate the LUT on cmsFloat32Number-basis.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1310
static
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1311
void _LUTevalFloat(register const cmsFloat32Number In[], register cmsFloat32Number Out[], const void* D)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1312
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1313
    cmsPipeline* lut = (cmsPipeline*) D;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1314
    cmsStage *mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1315
    cmsFloat32Number Storage[2][MAX_STAGE_CHANNELS];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1316
    int Phase = 0, NextPhase;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1317
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1318
    memmove(&Storage[Phase][0], In, lut ->InputChannels  * sizeof(cmsFloat32Number));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1319
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1320
    for (mpe = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1321
         mpe != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1322
         mpe = mpe ->Next) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1323
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1324
              NextPhase = Phase ^ 1;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1325
              mpe ->EvalPtr(&Storage[Phase][0], &Storage[NextPhase][0], mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1326
              Phase = NextPhase;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1327
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1328
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1329
    memmove(Out, &Storage[Phase][0], lut ->OutputChannels * sizeof(cmsFloat32Number));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1335
// LUT Creation & Destruction
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1336
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1337
cmsPipeline* CMSEXPORT cmsPipelineAlloc(cmsContext ContextID, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1339
       cmsPipeline* NewLUT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1341
       if (InputChannels >= cmsMAXCHANNELS ||
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1342
           OutputChannels >= cmsMAXCHANNELS) return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1344
       NewLUT = (cmsPipeline*) _cmsMallocZero(ContextID, sizeof(cmsPipeline));
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1345
       if (NewLUT == NULL) return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1348
       NewLUT -> InputChannels  = InputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1349
       NewLUT -> OutputChannels = OutputChannels;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1351
       NewLUT ->Eval16Fn    = _LUTeval16;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1352
       NewLUT ->EvalFloatFn = _LUTevalFloat;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1353
       NewLUT ->DupDataFn   = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1354
       NewLUT ->FreeDataFn  = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1355
       NewLUT ->Data        = NewLUT;
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1356
       NewLUT ->ContextID   = ContextID;
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
  1357
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1358
       BlessLUT(NewLUT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
       return NewLUT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1363
cmsContext CMSEXPORT cmsGetPipelineContextID(const cmsPipeline* lut)
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1364
{
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1365
    _cmsAssert(lut != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1366
    return lut ->ContextID;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1367
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1369
cmsUInt32Number CMSEXPORT cmsPipelineInputChannels(const cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1370
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1371
    _cmsAssert(lut != NULL);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1372
    return lut ->InputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1373
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1375
cmsUInt32Number CMSEXPORT cmsPipelineOutputChannels(const cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1376
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1377
    _cmsAssert(lut != NULL);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1378
    return lut ->OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1379
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1380
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1381
// Free a profile elements LUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1382
void CMSEXPORT cmsPipelineFree(cmsPipeline* lut)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1384
    cmsStage *mpe, *Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1385
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1386
    if (lut == NULL) return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1387
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1388
    for (mpe = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1389
        mpe != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1390
        mpe = Next) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1392
            Next = mpe ->Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1393
            cmsStageFree(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1394
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1396
    if (lut ->FreeDataFn) lut ->FreeDataFn(lut ->ContextID, lut ->Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1397
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1398
    _cmsFree(lut ->ContextID, lut);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1402
// Default to evaluate the LUT on 16 bit-basis.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1403
void CMSEXPORT cmsPipelineEval16(const cmsUInt16Number In[], cmsUInt16Number Out[],  const cmsPipeline* lut)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1405
    _cmsAssert(lut != NULL);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1406
    lut ->Eval16Fn(In, Out, lut->Data);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1407
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1410
// Does evaluate the LUT on cmsFloat32Number-basis.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1411
void CMSEXPORT cmsPipelineEvalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1412
{
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1413
    _cmsAssert(lut != NULL);
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1414
    lut ->EvalFloatFn(In, Out, lut);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1419
// Duplicates a LUT
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1420
cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* lut)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1422
    cmsPipeline* NewLUT;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1423
    cmsStage *NewMPE, *Anterior = NULL, *mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1424
    cmsBool  First = TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1426
    if (lut == NULL) return NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1428
    NewLUT = cmsPipelineAlloc(lut ->ContextID, lut ->InputChannels, lut ->OutputChannels);
18210
662eb8b3dfb5 8007925: Improve cmsStageAllocLabV2ToV4curves
jgodinez
parents: 14300
diff changeset
  1429
    if (NewLUT == NULL) return NULL;
662eb8b3dfb5 8007925: Improve cmsStageAllocLabV2ToV4curves
jgodinez
parents: 14300
diff changeset
  1430
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1431
    for (mpe = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1432
         mpe != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1433
         mpe = mpe ->Next) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1435
             NewMPE = cmsStageDup(mpe);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1437
             if (NewMPE == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1438
                 cmsPipelineFree(NewLUT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1439
                 return NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1440
             }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1442
             if (First) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1443
                 NewLUT ->Elements = NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1444
                 First = FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1445
             }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1446
             else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1447
                Anterior ->Next = NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1448
             }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1450
            Anterior = NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1451
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1453
    NewLUT ->Eval16Fn    = lut ->Eval16Fn;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1454
    NewLUT ->EvalFloatFn = lut ->EvalFloatFn;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1455
    NewLUT ->DupDataFn   = lut ->DupDataFn;
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1456
    NewLUT ->FreeDataFn  = lut ->FreeDataFn;
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1457
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1458
    if (NewLUT ->DupDataFn != NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1459
        NewLUT ->Data = NewLUT ->DupDataFn(lut ->ContextID, lut->Data);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1462
    NewLUT ->SaveAs8Bits    = lut ->SaveAs8Bits;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1464
    BlessLUT(NewLUT);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1465
    return NewLUT;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1469
void CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1471
    cmsStage* Anterior = NULL, *pt;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1472
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1473
    _cmsAssert(lut != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1474
    _cmsAssert(mpe != NULL);
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1475
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1476
    switch (loc) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1477
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1478
        case cmsAT_BEGIN:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1479
            mpe ->Next = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1480
            lut ->Elements = mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1481
            break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1483
        case cmsAT_END:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1484
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1485
            if (lut ->Elements == NULL)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1486
                lut ->Elements = mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1487
            else {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1488
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1489
                for (pt = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1490
                     pt != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1491
                     pt = pt -> Next) Anterior = pt;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1492
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1493
                Anterior ->Next = mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1494
                mpe ->Next = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1495
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1496
            break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1497
        default:;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1498
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1499
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1500
    BlessLUT(lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1501
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1502
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1503
// Unlink an element and return the pointer to it
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1504
void CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1505
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1506
    cmsStage *Anterior, *pt, *Last;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1507
    cmsStage *Unlinked = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1510
    // If empty LUT, there is nothing to remove
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1511
    if (lut ->Elements == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1512
        if (mpe) *mpe = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1513
        return;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1514
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1516
    // On depending on the strategy...
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1517
    switch (loc) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1519
        case cmsAT_BEGIN:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1520
            {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1521
                cmsStage* elem = lut ->Elements;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1523
                lut ->Elements = elem -> Next;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1524
                elem ->Next = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1525
                Unlinked = elem;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1527
            }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1528
            break;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1530
        case cmsAT_END:
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1531
            Anterior = Last = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1532
            for (pt = lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1533
                pt != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1534
                pt = pt -> Next) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1535
                    Anterior = Last;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1536
                    Last = pt;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1537
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1539
            Unlinked = Last;  // Next already points to NULL
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1541
            // Truncate the chain
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1542
            if (Anterior)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1543
                Anterior ->Next = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1544
            else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1545
                lut ->Elements = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1546
            break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1547
        default:;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1548
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1550
    if (mpe)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1551
        *mpe = Unlinked;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1552
    else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1553
        cmsStageFree(Unlinked);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1555
    BlessLUT(lut);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1559
// Concatenate two LUT into a new single one
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1560
cmsBool  CMSEXPORT cmsPipelineCat(cmsPipeline* l1, const cmsPipeline* l2)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1561
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1562
    cmsStage* mpe, *NewMPE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1563
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1564
    // If both LUTS does not have elements, we need to inherit
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1565
    // the number of channels
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1566
    if (l1 ->Elements == NULL && l2 ->Elements == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1567
        l1 ->InputChannels  = l2 ->InputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1568
        l1 ->OutputChannels = l2 ->OutputChannels;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1569
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1570
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1571
    // Cat second
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1572
    for (mpe = l2 ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1573
         mpe != NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1574
         mpe = mpe ->Next) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1575
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1576
            // We have to dup each element
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1577
             NewMPE = cmsStageDup(mpe);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1578
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1579
             if (NewMPE == NULL) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1580
                 return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1581
             }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1582
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1583
             cmsPipelineInsertStage(l1, cmsAT_END, NewMPE);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1584
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1585
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1586
  BlessLUT(l1);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1587
  return TRUE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1588
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1589
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1590
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1591
cmsBool CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lut, cmsBool On)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1592
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1593
    cmsBool Anterior = lut ->SaveAs8Bits;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1594
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1595
    lut ->SaveAs8Bits = On;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1596
    return Anterior;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1597
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1598
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1599
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1600
cmsStage* CMSEXPORT cmsPipelineGetPtrToFirstStage(const cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1601
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1602
    return lut ->Elements;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1603
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1604
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1605
cmsStage* CMSEXPORT cmsPipelineGetPtrToLastStage(const cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1606
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1607
    cmsStage *mpe, *Anterior = NULL;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1608
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1609
    for (mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1610
        Anterior = mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1611
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1612
    return Anterior;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1613
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1614
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1615
cmsUInt32Number CMSEXPORT cmsPipelineStageCount(const cmsPipeline* lut)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1616
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1617
    cmsStage *mpe;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1618
    cmsUInt32Number n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1619
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1620
    for (n=0, mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1621
            n++;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1622
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1623
    return n;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1624
}
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1625
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1626
// This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1627
// duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1628
void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1629
                                        _cmsOPTeval16Fn Eval16,
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1630
                                        void* PrivateData,
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1631
                                        _cmsFreeUserDataFn FreePrivateDataFn,
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1632
                                        _cmsDupUserDataFn  DupPrivateDataFn)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1633
{
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1634
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1635
    Lut ->Eval16Fn = Eval16;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1636
    Lut ->DupDataFn = DupPrivateDataFn;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1637
    Lut ->FreeDataFn = FreePrivateDataFn;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1638
    Lut ->Data = PrivateData;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1639
}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
// ----------------------------------------------------------- Reverse interpolation
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
// Here's how it goes. The derivative Df(x) of the function f is the linear
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
// transformation that best approximates f near the point x. It can be represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
// by a matrix A whose entries are the partial derivatives of the components of f
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
// with respect to all the coordinates. This is know as the Jacobian
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
// The best linear approximation to f is given by the matrix equation:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
// y-y0 = A (x-x0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
// So, if x0 is a good "guess" for the zero of f, then solving for the zero of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
// linear approximation will give a "better guess" for the zero of f. Thus let y=0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
// and since y0=f(x0) one can solve the above equation for x. This leads to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
// Newton's method formula:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
// xn+1 = xn - A-1 f(xn)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
// where xn+1 denotes the (n+1)-st guess, obtained from the n-th guess xn in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
// fashion described above. Iterating this will give better and better approximations
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
// if you have a "good enough" initial guess.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1664
#define JACOBIAN_EPSILON            0.001f
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
#define INVERSION_MAX_ITERATIONS    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
// Increment with reflexion on boundary
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
static
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1669
void IncDelta(cmsFloat32Number *Val)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
    if (*Val < (1.0 - JACOBIAN_EPSILON))
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
        *Val += JACOBIAN_EPSILON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
        *Val -= JACOBIAN_EPSILON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1682
// Euclidean distance between two vectors of n elements each one
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
static
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1684
cmsFloat32Number EuclideanDistance(cmsFloat32Number a[], cmsFloat32Number b[], int n)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1686
    cmsFloat32Number sum = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1687
    int i;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1689
    for (i=0; i < n; i++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1690
        cmsFloat32Number dif = b[i] - a[i];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1691
        sum +=  dif * dif;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1692
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1694
    return sqrtf(sum);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1698
// Evaluate a LUT in reverse direction. It only searches on 3->3 LUT. Uses Newton method
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1699
//
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
// x1 <- x - [J(x)]^-1 * f(x)
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1701
//
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1702
// lut: The LUT on where to do the search
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1703
// Target: LabK, 3 values of Lab plus destination K which is fixed
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1704
// Result: The obtained CMYK
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1705
// Hint:   Location where begin the search
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1707
cmsBool CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1708
                                              cmsFloat32Number Result[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1709
                                              cmsFloat32Number Hint[],
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1710
                                              const cmsPipeline* lut)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
{
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1712
    cmsUInt32Number  i, j;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1713
    cmsFloat64Number  error, LastError = 1E20;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1714
    cmsFloat32Number  fx[4], x[4], xd[4], fxd[4];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1715
    cmsVEC3 tmp, tmp2;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1716
    cmsMAT3 Jacobian;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1717
    cmsFloat64Number LastResult[4];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1720
    // Only 3->3 and 4->3 are supported
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1721
    if (lut ->InputChannels != 3 && lut ->InputChannels != 4) return FALSE;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1722
    if (lut ->OutputChannels != 3) return FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1724
    // Mark result of -1
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1725
    LastResult[0] = LastResult[1] = LastResult[2] = -1.0f;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1726
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1727
    // Take the hint as starting point if specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1728
    if (Hint == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1729
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1730
        // Begin at any point, we choose 1/3 of CMY axis
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1731
        x[0] = x[1] = x[2] = 0.3f;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1732
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1733
    else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1734
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1735
        // Only copy 3 channels from hint...
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1736
        for (j=0; j < 3; j++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1737
            x[j] = Hint[j];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1738
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1739
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1740
    // If Lut is 4-dimensions, then grab target[3], which is fixed
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1741
    if (lut ->InputChannels == 4) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1742
        x[3] = Target[3];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1743
    }
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1744
    else x[3] = 0; // To keep lint happy
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1745
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1746
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1747
    // Iterate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1748
    for (i = 0; i < INVERSION_MAX_ITERATIONS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1749
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1750
        // Get beginning fx
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1751
        cmsPipelineEvalFloat(x, fx, lut);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1752
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1753
        // Compute error
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1754
        error = EuclideanDistance(fx, Target, 3);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1755
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1756
        // If not convergent, return last safe value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1757
        if (error >= LastError)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1758
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1759
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1760
        // Keep latest values
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1761
        LastError     = error;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1762
        for (j=0; j < lut ->InputChannels; j++)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1763
                Result[j] = x[j];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1764
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1765
        // Found an exact match?
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1766
        if (error <= 0)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1767
            break;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1768
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1769
        // Obtain slope (the Jacobian)
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1770
        for (j = 0; j < 3; j++) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1771
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1772
            xd[0] = x[0];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1773
            xd[1] = x[1];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1774
            xd[2] = x[2];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1775
            xd[3] = x[3];  // Keep fixed channel
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1776
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1777
            IncDelta(&xd[j]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1778
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1779
            cmsPipelineEvalFloat(xd, fxd, lut);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1780
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1781
            Jacobian.v[0].n[j] = ((fxd[0] - fx[0]) / JACOBIAN_EPSILON);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1782
            Jacobian.v[1].n[j] = ((fxd[1] - fx[1]) / JACOBIAN_EPSILON);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1783
            Jacobian.v[2].n[j] = ((fxd[2] - fx[2]) / JACOBIAN_EPSILON);
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1784
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1785
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
  1786
        // Solve system
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1787
        tmp2.n[0] = fx[0] - Target[0];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1788
        tmp2.n[1] = fx[1] - Target[1];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1789
        tmp2.n[2] = fx[2] - Target[2];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1790
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1791
        if (!_cmsMAT3solve(&tmp, &Jacobian, &tmp2))
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1792
            return FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1793
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1794
        // Move our guess
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1795
        x[0] -= (cmsFloat32Number) tmp.n[0];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1796
        x[1] -= (cmsFloat32Number) tmp.n[1];
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1797
        x[2] -= (cmsFloat32Number) tmp.n[2];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1798
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1799
        // Some clipping....
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1800
        for (j=0; j < 3; j++) {
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1801
            if (x[j] < 0) x[j] = 0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1802
            else
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1803
                if (x[j] > 1.0) x[j] = 1.0;
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1804
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1805
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1806
6482
0f6a4442b29e 6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents: 5506
diff changeset
  1807
    return TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1808
}
2394
404cbe399601 6821031: Upgrade OpenJDK's LittleCMS version to 1.18
prr
parents: 2
diff changeset
  1809
14300
117dc9b98a7b 7053526: Upgrade JDK 8 to use Little CMS 2.4
bae
parents: 6482
diff changeset
  1810