1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
|
/* Standardized display types */
/* Standardized display types for use with libinst */
/*
* Argyll Color Correction System
*
* Author: Graeme W. Gill
* Date: 14/5/2014
*
* Copyright 2014 Graeme W. Gill
* All rights reserved.
*
* This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :-
* see the License2.txt file for licencing details.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#ifndef SALONEINSTLIB
#include "copyright.h"
#include "aconfig.h"
#include "icc.h"
#else
#include "sa_config.h"
#endif /* !SALONEINSTLIB */
#include "numsup.h"
#include "conv.h"
#include "disptechs.h"
/* Other selection characters used,
that shouldn't be used in the disptech_info_array[] entries :
"n" Non-refresh (Generic)
"r" Refresh (Generic)
"F" Factory base calibration
"R" Raw sensor values
"g" Generic
oemarch:
"C" CMF
"U" Custom
kleink10:
"P" DLP projector using ambient
"E" SMPTE C
"P" Klein DLP Lux
"d" Klein LED Bk LCD
"O" Sony EL OLED
"z" Eizo CG LCD
*/
/* We deliberately duplicate the selection characters, */
/* because it's not usual to offer the whole list, just */
/* a sub-set, which may not clash. */
/* disptechs_set_sel() should be used to present */
/* unique selectors. */
static disptech_info disptech_info_array[] = {
{
disptech_none, /* Not applicable entry. Must be first */
"None", /* because disptech_get_list() assumes so */
"None",
0,
0.001,
0.001,
NULL
},
{
disptech_crt,
"CRT",
"CRT",
1,
DISPTECH_CRT_RISE,
DISPTECH_CRT_FALL,
"c"
},
{
disptech_plasma,
"Plasma",
"Plasma",
1,
DISPTECH_CRT_RISE,
DISPTECH_CRT_FALL,
"m"
},
{
disptech_lcd,
"LCD",
"LCD",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"l"
},
{
disptech_lcd_ccfl,
"LCD CCFL",
"LCD CCFL",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"l"
},
{
disptech_lcd_ccfl_ips,
"LCD CCFL IPS",
"LCD CCFL IPS",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"l"
},
{ disptech_lcd_ccfl_vpa,
"LCD CCFL VPA",
"LCD CCFL VPA",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"l"
},
{ disptech_lcd_ccfl_tft,
"LCD CCFL TFT",
"LCD CCFL TFT",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"l"
},
{ disptech_lcd_ccfl_wg,
"LCD CCFL Wide Gamut",
"LCD CCFL Wide Gamut",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"L"
},
{ disptech_lcd_ccfl_wg_ips,
"LCD CCFL Wide Gamut IPS",
"LCD CCFL Wide Gamut IPS",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"L"
},
{ disptech_lcd_ccfl_wg_vpa,
"LCD CCFL Wide Gamut VPA",
"LCD CCFL Wide Gamut VPA",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"L"
},
{ disptech_lcd_ccfl_wg_tft,
"LCD CCFL Wide Gamut TFT",
"LCD CCFL Wide Gamut TFT",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"L"
},
{ disptech_lcd_wled,
"LCD White LED",
"LCD White LED",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"e"
},
{ disptech_lcd_wled_ips,
"LCD White LED IPS",
"LCD White LED IPS",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"e"
},
{ disptech_lcd_wled_vpa,
"LCD White LED VPA",
"LCD White LED VPA",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"e"
},
{ disptech_lcd_wled_tft,
"LCD White LED TFT",
"LCD White LED TFT",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"e"
},
{ disptech_lcd_rgbled,
"LCD RGB LED",
"LCD RGB LED",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"b"
},
{ disptech_lcd_rgbled_ips,
"LCD RGB LED IPS",
"LCD RGB LED IPS",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"b"
},
{ disptech_lcd_rgbled_vpa,
"LCD RGB LED VPA",
"LCD RGB LED VPA",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"b"
},
{ disptech_lcd_rgbled_tft,
"LCD RGB LED TFT",
"LCD RGB LED TFT",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"b"
},
{ disptech_lcd_rgledp,
"LCD RG Phosphor",
"LCD RG Phosphor",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"h"
},
{ disptech_lcd_rgledp_ips,
"LCD RG Phosphor IPS",
"LCD RG Phosphor IPS",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"h"
},
{ disptech_lcd_rgledp_vpa,
"LCD RG Phosphor VPA",
"LCD RG Phosphor VPA",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"h"
},
{ disptech_lcd_rgledp_tft,
"LCD RG Phosphor TFT",
"LCD RG Phosphor TFT",
0,
DISPTECH_LCD_RISE,
DISPTECH_LCD_FALL,
"h"
},
{ disptech_oled,
"LED OLED",
"LED OLED",
0,
DISPTECH_LED_RISE,
DISPTECH_LED_FALL,
"o"
},
{ disptech_amoled,
"LED AMOLED",
"LED AMOLED",
0,
DISPTECH_LED_RISE,
DISPTECH_LED_FALL,
"a"
},
{ disptech_dlp,
"Projector",
"DLP Projector",
1,
DISPTECH_DLP_RISE,
DISPTECH_DLP_FALL,
"p"
},
{ disptech_dlp_rgb,
"Projector RGB Filter Wheel",
"DLP Projector RGB Filter Wheel",
1,
DISPTECH_DLP_RISE,
DISPTECH_DLP_FALL,
"p"
},
{ disptech_dlp_rgbw,
"Projector RGBW Filter Wheel",
"DPL Projector RGBW Filter Wheel",
1,
DISPTECH_DLP_RISE,
DISPTECH_DLP_FALL,
"p"
},
{ disptech_dlp_rgbcmy,
"Projector RGBCMY Filter Wheel",
"DLP Projector RGBCMY Filter Wheel",
1,
DISPTECH_DLP_RISE,
DISPTECH_DLP_FALL,
"p"
},
{
disptech_unknown,
"Unknown",
"Unknown",
1,
DISPTECH_WORST_RISE,
DISPTECH_WORST_FALL,
"u"
},
{
disptech_end /* End marker */
}
};
static int unknown_ix = -1;
static void find_unknown() {
int i;
for (i = 0; disptech_info_array[i].dtech != disptech_end; i++) {
if (disptech_info_array[i].dtech == disptech_unknown) {
unknown_ix = i;
break;
}
}
}
/* Given the enum id, return the matching disptech_info entry */
/* Return the disptech_unknown entry if not matched */
disptech_info *disptech_get_id(disptech id) {
int i;
for (i = 0; disptech_info_array[i].dtech != disptech_end; i++) {
if (disptech_info_array[i].dtech == id)
return &disptech_info_array[i];
}
if (unknown_ix < 0)
find_unknown();
return &disptech_info_array[unknown_ix];
}
/* Given the string id, return the matching disptech_info entry */
/* Return the disptech_unknown entry if not matched */
disptech_info *disptech_get_strid(char *strid) {
int i;
for (i = 0; disptech_info_array[i].dtech != disptech_end; i++) {
if (strcmp(disptech_info_array[i].strid, strid) == 0)
return &disptech_info_array[i];
}
if (unknown_ix < 0)
find_unknown();
return &disptech_info_array[unknown_ix];
}
/* For each selector we need to:
check each selector char
if already used,
remove it.
if no selector remain,
allocate a free one from the fallback list.
mark all used selectors
We treat the first selector as more important
than any aliases that come after it, and the
aliases as more important than the fallback list,
so we need to do three passes through all the selections.
*/
/* Set the selection characters. */
/* Return NZ if we have not set all selectors */
/* If a selector is set, its index will be set in usels[], */
/* and any remaining selection characters deleted. */
/* If flag == 0, set from just first suggested selector */
/* If flag == 1, set from just suggested selector */
/* If flag == 2, set from suggested and fallback selectors */
/* If flag == 3, set from suggested and fallback selectors, and set unset to nul */
int disptechs_set_sel(
int flag, /* See above */
int ix, /* Index of entry being set */
char *sel, /* Pointer to string list of suggested selectors, */
/* return a single unique selector in string. */
char *usels, /* char[256] initially -1, to track used selector entry index */
int *k, /* Index of next available selector in asels */
char *asels /* String list of fallback selectors to choose from, in order. */
) {
char *d, *s, i;
//a1logd(g_log, 1,"disptechs_set_sel: flag %d, ix %d, sel '%s', k %d\n",flag, ix,sel,*k);
/* See if this has already been allocated */
if (usels[*sel] == ix) {
//a1logd(g_log, 1," set OK\n");
return 0; /* Nothing to do */
}
/* Set from the suggested selectors */
for (i = 0, s = sel; *s != '\000'; s++, i++) {
if (flag == 0 && i > 0) {
//a1logd(g_log, 1," run out of primaries\n");
break; /* Looked at primary */
}
if (usels[*s] == ((char)-1)) { /* If this selector is not currently used */
//a1logd(g_log, 1," set to '%c' at %d\n", *s, i);
sel[0] = *s; /* Use it */
sel[1] = '\000';
usels[*s] = ix;
return 0;
}
//a1logd(g_log, 1," sel '%c' at %d is used by ix %d\n", *s, i, usels[*s]);
}
if (flag <= 2) {
//a1logd(g_log, 1," returning unset\n");
return 1;
}
/* Get the next unused char in fallback list */
for (;asels[*k] != '\000'; (*k)++) {
if (usels[asels[*k]] == ((char)-1)) /* Unused */
break;
}
if (asels[*k] != '\000') {
//a1logd(g_log, 1," set int to fallback '%c' at %d\n", asels[*k], *k);
sel[0] = asels[*k];
sel[1] = '\000';
usels[sel[0]] = ix;
(*k)++;
return 0;
}
/* Set any unset to nul */
if (flag >= 3) {
//a1logd(g_log, 1," clearing\n");
sel[0] = '\000';
}
//a1logd(g_log, 1," failed\n");
/* If we got here, we failed */
return 1;
}
/* Return the display tech list with unique lsel lectors */
disptech_info *disptech_get_list() {
disptech_info *list = &disptech_info_array[1]; /* skip disptech_none entry */
int i, k;
char usels[256]; /* Used selectors */
static char *asels = "123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (i = 0; i < 256; i++)
usels[i] = ((char)-1);
k = 0; /* Next selector index */
/* Add entries from the static list and their primary selectors */
for (i = 0; list[i].dtech != disptech_end; i++) {
//a1logd(1,"tech[%d] '%s' sels = '%s'\n",i,list[i].desc,list[i].sel);
strcpy(list[i].lsel, list[i].sel);
disptechs_set_sel(0, i, list[i].lsel, usels, &k, asels);
}
/* Set selectors from secondary */
for (i = 0; list[i].dtech != disptech_end; i++)
disptechs_set_sel(1, i, list[i].lsel, usels, &k, asels);
/* Set remainder from fallback */
for (i = 0; list[i].dtech != disptech_end; i++)
disptechs_set_sel(3, i, list[i].lsel, usels, &k, asels);
return list;
}
/* Locate the display list item that matches the given selector. */
/* Return NULL if not found */
disptech_info *disptech_select(disptech_info *list, char c) {
int i;
for (i = 0; list[i].dtech != disptech_end; i++) {
if (c == list[i].lsel[0])
return &list[i];
}
return NULL;
}
/* ------------------------------------------- */
/*
Display settling time model. This is primarily tailored
to phosphor type response (ie. CRT or Plasma), but LCD
should be somewhat similar
Outline:
Use sRGB as the device model.
For the target RGB, compute the partial derivative of
delta E with respect to R, G & B, and then multiply
that by desired dE accuracy to get the target R, G & B
delta from the target, and then put that into
the exponential rise/fall model to compute settling time.
Choose the worst of the 3.
Should really change the code to compute partial derivative
directly, to speed code up.
We assume the phosphor stimulus is the proportional to the
light output required (ie. that the CRT/encoding non-linearity
is in the electron gun, not the electron->phoshor->light mechanism. )
*/
/* Convert gamma encoded rgb to linear light rgb */
static void rgb2rgbl(double *rgbl, double *rgb) {
int i;
for (i = 0; i < 3; i++) {
if (rgb[i] < 0.04045)
rgbl[i] = rgb[i]/12.92;
else
rgbl[i] = pow((rgb[i] + 0.055)/1.055, 2.4);
}
}
/* Convert linear light rgb to L*a*b* */
static void rgbl2lab(double *lab, double *rgbl) {
int i;
double xyz[3];
static double mat[3][3] = {
{ 0.412391, 0.212639, 0.019331 }, /* Red */
{ 0.357584, 0.715169, 0.119195 }, /* Green */
{ 0.180481, 0.072192, 0.950532 } /* Blue */
};
icmMulBy3x3(xyz, mat, rgbl);
icmXYZ2Lab(&icmD65, lab, xyz);
}
#ifdef NEVER
/* Convert linear light rgb to L*a*b* with partial derivatives */
static void ddrgbl2lab(double *lab, double dout[3][3], double *rgbl) {
int i, j, k;
double xyz[3];
static double mat[9] = {
0.412391, 0.212639, 0.019331, /* Red */
0.357584, 0.715169, 0.119195, /* Green */
0.180481, 0.072192, 0.950532 /* Blue */
};
double dxyzlab[3][3]; /* Part. Deriv of [xyz] with respect to [rgb] */
double dlabxyz[3][3]; /* Part. Deriv of [lab] from [xyz] */
icxdpdiiMulBy3x3Parm(xyz, dxyzlab, mat, rgbl);
icxdXYZ2Lab(&icmD65, lab, dlabxyz, xyz);
/* Compute the partial derivative of Lab from rgb */
for (k = 0; k < 3; k++) {
for (j = 0; j < 3; j++) {
dout[k][j] = 0.0;
for (i = 0; i < 3; i++) {
dout[k][j] += dlabxyz[k][i] * dxyzlab[i][j];
}
}
}
}
#endif /* NEVER */
/* Convert linear light rgb to L*a*b* delta E partial derivatives */
static void drgbl2lab(/* double *lab, */double deout[3], double *rgbl) {
int i, j, k;
static double mat[3][3] = {
{ 0.412391, 0.212639, 0.019331 }, /* Red */
{ 0.357584, 0.715169, 0.119195 }, /* Green */
{ 0.180481, 0.072192, 0.950532 } /* Blue */
};
double xyz[3];
double wp[3], tin[3], dtin[3];
double dlabxyz[3][3]; /* Part. Deriv of [lab] from [xyz] */
double dout[3][3]; /* Part. Deriv of [lab] from [rgb] */
/* rgb to XYZ */
for (i = 0; i < 3; i++) {
xyz[i] = 0.0;
for (j = 0; j < 3; j++) {
xyz[i] += mat[i][j] * rgbl[j];
}
}
/* XYZ to perceptual Lab with partial derivatives. */
wp[0] = icmD65.X, wp[1] = icmD65.Y, wp[2] = icmD65.Z;
for (i = 0; i < 3; i++) {
tin[i] = xyz[i]/wp[i];
dtin[i] = 1.0/wp[i];
if (tin[i] > 0.008856451586) {
dtin[i] *= pow(tin[i], -2.0/3.0) / 3.0;
tin[i] = pow(tin[i],1.0/3.0);
} else {
dtin[i] *= 7.787036979;
tin[i] = 7.787036979 * tin[i] + 16.0/116.0;
}
}
/* lab[0] = 116.0 * tin[1] - 16.0; */
dlabxyz[0][0] = 0.0;
dlabxyz[0][1] = 116.0 * dtin[1];
dlabxyz[0][2] = 0.0;
/* lab[1] = 500.0 * (tin[0] - tin[1]); */
dlabxyz[1][0] = 500.0 * dtin[0];
dlabxyz[1][1] = 500.0 * -dtin[1];
dlabxyz[1][2] = 0.0;
/* lab[2] = 200.0 * (tin[1] - tin[2]); */
dlabxyz[2][0] = 0.0 * mat[0][1];
dlabxyz[2][1] = 200.0 * dtin[1];
dlabxyz[2][2] = 200.0 * -dtin[2];
/* Compute the partial derivative of delta E from rgb */
for (j = 0; j < 3; j++) {
deout[j] = 0.0;
for (k = 0; k < 3; k++) {
dout[k][j] = 0.0;
for (i = 0; i < 3; i++) {
dout[k][j] += dlabxyz[k][i] * mat[i][j];
}
deout[j] += dout[k][j] * dout[k][j];
}
deout[j] = sqrt(deout[j]);
}
}
double disp_settle_time(double *orgb, double *nrgb, double rise, double fall, double dE) {
int i, j;
double orgbl[3], nrgbl[3]; /* Linear light RGB */
double drgb[3]; /* Partial derivative of RGB wrt to dE at new rgb */
double argbl[3]; /* Acceptable RGB */
double stime[3]; /* Settling time */
double kr, kf;
double xtime = 0.0;
/* Convert rgb's to linear light rgb */
rgb2rgbl(orgbl, orgb);
rgb2rgbl(nrgbl, nrgb);
//printf("orgb = %f %f %f\n", orgb[0], orgb[1], orgb[2]);
//printf("nrgb = %f %f %f\n", nrgb[0], nrgb[1], nrgb[2]);
//printf("orgbl = %f %f %f\n", orgbl[0], orgbl[1], orgbl[2]);
//printf("nrgbl = %f %f %f\n", nrgbl[0], nrgbl[1], nrgbl[2]);
//printf("dE = %f\n", dE);
/* Compute partial derivative */
drgbl2lab(drgb, nrgbl);
//printf("drgb = %f %f %f\n", drgb[0], drgb[1], drgb[2]);
#ifdef NEVER
/* Calculate partial derivative explicitely to check */
{
double rlab[3], lab[3];
double xdrgb[3]; /* Partial derivative of RGB wrt to dE at new rgb */
/* Reference Lab */
rgbl2lab(rlab, nrgbl);
//printf("rlab = %f %f %f\n", rlab[0], rlab[1], rlab[2]);
for (j = 0; j < 3; j++) {
double del;
if (nrgbl[j] > 0.5)
del = -1e-6;
else
del = 1e-6;
nrgbl[j] += del;
rgbl2lab(lab, nrgbl);
nrgbl[j] -= del;
//printf("check pde of in %d = lab %f, %f, %f\n",j, (lab[0] - rlab[0])/del, (lab[1] - rlab[1])/del, (lab[2] - rlab[2])/del);
xdrgb[j] = icmLabDE(rlab, lab)/fabs(del);
}
printf("chk drgb = %f %f %f\n", xdrgb[0], xdrgb[1], xdrgb[2]);
}
#endif /* NEVER */
/* Compute rgb value that would give targ delta E */
for (j = 0; j < 3; j++) {
double del;
del = dE/drgb[j];
if (orgbl[j] < nrgbl[j]) {
argbl[j] = nrgbl[j] - del;
if (argbl[j] < orgbl[j])
argbl[j] = orgbl[j];
} else {
argbl[j] = nrgbl[j] + del;
if (argbl[j] > orgbl[j])
argbl[j] = orgbl[j];
}
}
//{ double rlab[3], lab[3];
//rgbl2lab(lab, argbl);
//rgbl2lab(rlab, nrgbl);
//printf("argbl = %f %f %f\n", argbl[0], argbl[1], argbl[2]);
//printf("dE for argbl = %f\n",icmLabDE(rlab, lab));
//}
/* Compute the modelled time from orgbl to argbl */
kr = rise/log(1.0 - 0.9); /* Exponent constant for 90% change*/
kf = fall/log(1.0 - 0.9); /* Exponent constant for 90% change*/
for (j = 0; j < 3; j++) {
double el, dl, n, t;
dl = (argbl[j] - orgbl[j])/(nrgbl[j] - orgbl[j]);
if (fabs(dl) < 1e-6) {
stime[j] = 0.0;
continue;
}
if (nrgbl[j] > orgbl[j])
stime[j] = kr * log(1.0 - dl);
else
stime[j] = kf * log(1.0 - dl);
if (stime[j] > xtime && stime[j] < 5.0)
xtime = stime[j];
}
//printf("stime = %f %f %f\n", stime[0], stime[1], stime[2]);
//printf("returning = %f\n",xtime);
return xtime;
}
|