lib/ICC/Profile/mBA_.pm

filter: Statementstmt 45.5% 211 / 463 Branchbran 22.2% 49 / 220 Conditioncond 11.2% 11 / 98 MC/DCmcdc 1.6% 1 / 59 Subroutinesub 33.3% 12 / 36 Podpod 9.5% 2 / 21 totaltotal 31.8% 286 / 897 CC 170 SCAR 40.2
CC
170
Cov
35%
inverse
240.0
transform
156.0
sdump
132.0
CRAP 56.0
« blib/lib/ICC/Support/Color.pm ↑ Summary blib/lib/ICC/Support/nNET.pm »
1 package ICC::Profile::mBA_;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = 2.51;
7  
8 # revised 2018-08-07
9 #
10 # Copyright © 2004-2018 by William B. Birkett
11  
12 # add development directory
13 2 ▶use lib 'lib';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # inherit from Shared
16 2 ▶use parent qw(ICC::Shared);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # use POSIX math
19 2 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 # create new mBA_ object
22 # hash may contain pointers to B-curves, matrix, M-curves, CLUT, or A-curves
23 # keys are: ('b_curves', 'matrix', 'm_curves', 'clut', 'a_curves')
24 # tag elements not specified in the hash are left empty
25 # parameters: ()
26 # parameters: (ref_to_attribute_hash)
27 # parameters: (ref_to_matrix-based_profile_object)
28 # returns: (ref_to_object)
29 sub new {
30  
31 # get object class
32 1 ▶ my $class = shift();
Subroutine new: called CC=6 SCAR=29.5
Pod undocumented
33  
34 # create empty mBA_ object
35 1 my $self = [
36 {}, # object header
37 [], # processing elements
38 0x00, # transform mask
39 0x00 # clipping mask
40 ];
41  
42 # if there are parameters
43 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 1 1
44
45 # if one parameter, a hash reference
46 0 ▶ if (@_ == 1 && ref($_[0]) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 0 0 0
elsif (@_ == 1 and UNIVERSAL::isa($_[0], 'ICC::Profile')) { } 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
47
48 # make new mBA_ tag from attribute hash
49 0 _new_from_hash($self, @_);
50
51 # if one parameter, an ICC::Profile object
52 ▶ } elsif (@_ == 1 && UNIVERSAL::isa($_[0], 'ICC::Profile')) {
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile")
@_ == 1 UNIVERSAL::isa($_[0], "ICC::Profile")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "ICC::Profile")
ABresult
0X0
100
111
53  
54 # make new mAB_ tag from ICC::Profile object
55 0 _newICCmatrix($self, @_);
56  
57 } else {
58
59 # error
60 0 croak('parameter must be a hash reference or a display matrix profile');
61
62 }
63
64 }
65  
66 # bless object
67 1 bless($self, $class);
68  
69 # return object reference
70 1 return($self);
71  
72 }
73  
74 # get/set reference to header hash
75 # parameters: ([ref_to_new_hash])
76 # returns: (ref_to_hash)
77 sub header {
78  
79 # get object reference
80 0 ▶ my $self = shift();
Subroutine header: not called CC=4 SCAR=30.0
Pod undocumented
81  
82 # if there are parameters
83 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
84
85 # if one parameter, a hash reference
86 0 ▶ if (@_ == 1 && ref($_[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0] eq 'HASH') { } 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
87
88 # set header to new hash
89 0 $self->[0] = shift();
90
91 } else {
92
93 # error
94 0 croak('parameter must be a hash reference');
95
96 }
97
98 }
99  
100 # return reference
101 0 return($self->[0]);
102  
103 }
104  
105 # get/set processing element array reference
106 # parameters: ([ref_to_array])
107 # returns: (ref_to_array)
108 sub array {
109  
110 # get object reference
111 0 ▶ my $self = shift();
Subroutine array: not called CC=3 SCAR=24.8
Pod undocumented
112  
113 # if parameter
114 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
115
116 # verify array reference
117 0 ▶ (ref($_[0]) eq 'ARRAY') or croak('not an array reference');
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq "ARRAY" or croak("not an array reference") 0 0 0
118
119 # set array reference
120 0 $self->[1] = [@{shift()}];
121
122 }
123  
124 # return array reference
125 0 return($self->[1]);
126  
127 }
128  
129 # get/set reference to B-curves 'cvst' object
130 # parameters: ([ref_to_new_object])
131 # returns: (ref_to_object)
132 sub b_curves {
133  
134 # get object reference
135 0 ▶ my $self = shift();
Subroutine b_curves: not called CC=4 SCAR=30.0
Pod undocumented
136  
137 # if there are parameters
138 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
139
140 # if one parameter, a 'cvst' object
141 0 ▶ if (@_ == 1 && UNIVERSAL::isa($_[0], 'ICC::Profile::cvst')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and UNIVERSAL::isa($_[0], 'ICC::Profile::cvst')) { } 0 0 0
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
@_ == 1 UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
ABresult
0X0
100
111
142
143 # set B-curves to new object
144 0 $self->[1][0] = shift();
145
146 # set transform mask bit
147 0 $self->[2] |= 0x01;
148
149 } else {
150
151 # error
152 0 croak('parameter must be a \'cvst\' object');
153
154 }
155
156 }
157  
158 # return object reference
159 0 return($self->[1][0]);
160  
161 }
162  
163 # get/set reference to matrix 'matf' object
164 # parameters: ([ref_to_new_object])
165 # returns: (ref_to_object)
166 sub matrix {
167  
168 # get object reference
169 0 ▶ my $self = shift();
Subroutine matrix: not called CC=4 SCAR=30.0
Pod undocumented
170  
171 # if there are parameters
172 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
173
174 # if one parameter, an 'matf' object
175 0 ▶ if (@_ == 1 && UNIVERSAL::isa($_[0], 'ICC::Profile::matf')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and UNIVERSAL::isa($_[0], 'ICC::Profile::matf')) { } 0 0 0
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::matf")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::matf")
@_ == 1 UNIVERSAL::isa($_[0], "ICC::Profile::matf")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "ICC::Profile::matf")
ABresult
0X0
100
111
176
177 # set matrix to new object
178 0 $self->[1][1] = shift();
179
180 # set transform mask bit
181 0 $self->[2] |= 0x02;
182
183 } else {
184
185 # error
186 0 croak('parameter must be an \'matf\' object');
187
188 }
189
190 }
191  
192 # return object reference
193 0 return($self->[1][1]);
194  
195 }
196  
197 # get/set reference to M-curves 'cvst' object
198 # parameters: ([ref_to_new_object])
199 # returns: (ref_to_object)
200 sub m_curves {
201  
202 # get object reference
203 0 ▶ my $self = shift();
Subroutine m_curves: not called CC=4 SCAR=30.0
Pod undocumented
204  
205 # if there are parameters
206 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
207
208 # if one parameter, a 'cvst' object
209 0 ▶ if (@_ == 1 && UNIVERSAL::isa($_[0], 'ICC::Profile::cvst')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and UNIVERSAL::isa($_[0], 'ICC::Profile::cvst')) { } 0 0 0
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
@_ == 1 UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
ABresult
0X0
100
111
210
211 # set M-curves to new object
212 0 $self->[1][2] = shift();
213
214 # set transform mask bit
215 0 $self->[2] |= 0x04;
216
217 } else {
218
219 # error
220 0 croak('parameter must be a \'cvst\' object');
221
222 }
223
224 }
225  
226 # return object reference
227 0 return($self->[1][2]);
228  
229 }
230  
231 # get/set reference to CLUT 'clut' object
232 # parameters: ([ref_to_new_object])
233 # returns: (ref_to_object)
234 sub clut {
235  
236 # get object reference
237 0 ▶ my $self = shift();
Subroutine clut: not called CC=4 SCAR=30.0
Pod undocumented
238  
239 # if there are parameters
240 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
241
242 # if one parameter, a 'clut' object
243 0 ▶ if (@_ == 1 && UNIVERSAL::isa($_[0], 'ICC::Profile::clut')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and UNIVERSAL::isa($_[0], 'ICC::Profile::clut')) { } 0 0 0
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::clut")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::clut")
@_ == 1 UNIVERSAL::isa($_[0], "ICC::Profile::clut")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "ICC::Profile::clut")
ABresult
0X0
100
111
244
245 # set CLUT to new object
246 0 $self->[1][3] = shift();
247
248 # set transform mask bit
249 0 $self->[2] |= 0x08;
250
251 } else {
252
253 # error
254 0 croak('parameter must be a \'clut\' object');
255
256 }
257
258 }
259  
260 # return object reference
261 0 return($self->[1][3]);
262  
263 }
264  
265 # get/set reference to A-curves 'cvst' object
266 # parameters: ([ref_to_new_object])
267 # returns: (ref_to_object)
268 sub a_curves {
269  
270 # get object reference
271 0 ▶ my $self = shift();
Subroutine a_curves: not called CC=4 SCAR=30.0
Pod undocumented
272  
273 # if there are parameters
274 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
275
276 # if one parameter, a 'cvst' object
277 0 ▶ if (@_ == 1 && UNIVERSAL::isa($_[0], 'ICC::Profile::cvst')) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and UNIVERSAL::isa($_[0], 'ICC::Profile::cvst')) { } 0 0 0
Condition0%0/3
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
@_ == 1 UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
Truth table0%0/3
A and B
A= @_ == 1B= UNIVERSAL::isa($_[0], "ICC::Profile::cvst")
ABresult
0X0
100
111
278
279 # set A-curves to new object
280 0 $self->[1][4] = shift();
281
282 # set transform mask bit
283 0 $self->[2] |= 0x10;
284
285 } else {
286
287 # error
288 0 croak('parameter must be a \'cvst\' object');
289
290 }
291
292 }
293  
294 # return object reference
295 0 return($self->[1][4]);
296  
297 }
298  
299 # get/set transform mask
300 # bits 4-3-2-1-0 correpsond to A-CLUT-M-MATRIX-B
301 # parameters: ([new_mask_value])
302 # returns: (mask_value)
303 sub mask {
304  
305 # get object reference
306 0 ▶ my $self = shift();
Subroutine mask: not called CC=3 SCAR=24.8
Pod undocumented
307  
308 # if there are parameters
309 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
310
311 # if one parameter
312 0 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
313
314 # set object transform mask value
315 0 $self->[2] = shift();
316
317 } else {
318
319 # error
320 0 croak('more than one parameter');
321
322 }
323
324 }
325  
326 # return transform mask value
327 0 return($self->[2]);
328  
329 }
330  
331 # get/set clipping mask
332 # bits 4-3-2-1-0 correpsond to A-CLUT-M-MATRIX-B
333 # parameters: ([new_mask_value])
334 # returns: (mask_value)
335 sub clip {
336
337 # get object reference
338 0 ▶ my $self = shift();
Subroutine clip: not called CC=3 SCAR=24.8
Pod documented
339
340 # if there are parameters
341 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
342
343 # if one parameter
344 0 ▶ if (@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
345
346 # set object clipping mask value
347 0 $self->[3] = shift();
348
349 } else {
350
351 # error
352 0 croak('more than one parameter');
353
354 }
355
356 }
357
358 # return clipping mask value
359 0 return($self->[3]);
360
361 }
362  
363 # create mBA_ tag object from ICC profile
364 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
365 # returns: (ref_to_object)
366 sub new_fh {
367  
368 # get object class
369 1 ▶ my $class = shift();
Subroutine new_fh: called CC=2 SCAR=7.0
Pod undocumented
370  
371 # create empty mBA_ object
372 1 my $self = [
373 {}, # object header
374 [], # processing elements
375 0x00, # transform mask
376 0x00 # clipping mask
377 ];
378  
379 # verify 3 parameters
380 1 ▶ (@_ == 3) or croak('wrong number of parameters');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("wrong number of parameters") 0 1 1
381  
382 # read mBA_ data from profile
383 1 _readICCmBA_($self, @_);
384  
385 # bless object
386 1 bless($self, $class);
387  
388 # return object reference
389 1 return($self);
390  
391 }
392  
393 # writes mBA_ tag object to ICC profile
394 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
395 sub write_fh {
396  
397 # verify 4 parameters
398 1 ▶ (@_ == 4) or croak('wrong number of parameters');
Subroutine write_fh: called CC=2 SCAR=7.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 or croak("wrong number of parameters") 0 1 1
399  
400 # write mBA_ data to profile
401 1 goto &_writeICCmBA_;
402  
403 }
404  
405 # get tag size (for writing to profile)
406 # returns: (tag_clut_size)
407 sub size {
408  
409 # get parameters
410 3 ▶ my ($self) = @_;
Subroutine size: called CC=9 SCAR=22.3
Pod undocumented
411  
412 # local variables
413 3 my ($size);
414  
415 # set header size
416 3 $size = 32;
417  
418 # for each B-curve
419 3 for my $curve (@{$self->[1][0]->array()}) {
420
421 # add curve size
422 9 $size += $curve->size;
423
424 # pad to 4-bytes
425 9 $size += (-$size % 4);
426
427 }
428  
429 # if matrix defined
430 3 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) 3 0 3
431
432 # add matrix size (48 bytes)
433 3 $size += 48;
434
435 }
436  
437 # if M-curves defined
438 3 ▶ if (defined($self->[1][2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][2]) 3 0 3
439
440 # for each M-curve
441 3 for my $curve (@{$self->[1][2]->array()}) {
442
443 # add curve size
444 9 $size += $curve->size;
445
446 # pad to 4-bytes
447 9 $size += (-$size % 4);
448
449 }
450
451 }
452  
453 # if CLUT defined
454 3 ▶ if (defined($self->[1][3])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][3]) 3 0 3
455
456 # add CLUT size (nCLUT object)
457 3 ▶ $size += 20 + $self->[1][3]->_clut_size($self->[1][3][0]{'clut_bytes'} || 2);
Condition50%1/2
$self->[1][3][0]{'clut_bytes'} || 2
l!l
30
MC/DC0%0/1
$self->[1][3][0]{'clut_bytes'} || 2
$self->[1][3][0]{'clut_bytes'}
Truth table50%1/2
A
A= $self->[1][3][0]{'clut_bytes'}
Aresult
11
00
458
459 # pad to 4-byte boundary
460 3 $size += (-$size % 4);
461
462 }
463  
464 # if A-curves defined
465 3 ▶ if (defined($self->[1][4])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][4]) 3 0 3
466
467 # for each A-curve
468 3 for my $curve (@{$self->[1][4]->array()}) {
469
470 # add curve size
471 9 $size += $curve->size;
472
473 # pad to 4-bytes
474 9 $size += (-$size % 4);
475
476 }
477
478 }
479  
480 # return size
481 3 return($size);
482  
483 }
484  
485 # get number of input channels
486 # returns: (number)
487 sub cin {
488  
489 # get object reference
490 0 ▶ my $self = shift();
Subroutine cin: not called CC=1 SCAR=6.9
Pod undocumented
491  
492 # return
493 0 return($self->[1][0]->cin());
494  
495 }
496  
497 # get number of output channels
498 # returns: (number)
499 sub cout {
500  
501 # get object reference
502 0 ▶ my $self = shift();
Subroutine cout: not called CC=1 SCAR=6.9
Pod undocumented
503  
504 # return
505 0 return($self->[1][-1]->cout());
506  
507 }
508  
509 # transform data
510 # transform mask enables/disables individual tag elements
511 # clipping mask enables/disables individual tag output clipping
512 # supported input types:
513 # parameters: (list, [hash])
514 # parameters: (vector, [hash])
515 # parameters: (matrix, [hash])
516 # parameters: (Math::Matrix_object, [hash])
517 # parameters: (structure, [hash])
518 # returns: (same_type_as_input)
519 sub transform {
520  
521 # set hash value (0 or 1)
522 0 ▶ my $h = ref($_[-1]) eq 'HASH' ? 1 : 0;
Subroutine transform: not called CC=12 SCAR=50.5
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[-1] eq 'HASH' ? : 0 0 0
523  
524 # if input a 'Math::Matrix' object
525 0 ▶ if (@_ == $h + 2 && UNIVERSAL::isa($_[1], 'Math::Matrix')) {
Branch: 3 branches
BranchTrueFalseTotal
if (@_ == $h + 2 and UNIVERSAL::isa($_[1], 'Math::Matrix')) { } 0 0 0
elsif (@_ == $h + 2 and ref $_[1] eq 'ARRAY') { } 0 0 0
elsif (@_ == $h + 1 + grep({&Scalar::Util::looks_like_number($_);} @_)) { } 0 0 0
Condition0%0/3
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == $h + 2 and UNIVERSAL::isa($_[1], "Math::Matrix")
@_ == $h + 2 UNIVERSAL::isa($_[1], "Math::Matrix")
Truth table0%0/3
A and B
A= @_ == $h + 2B= UNIVERSAL::isa($_[1], "Math::Matrix")
ABresult
0X0
100
111
526
527 # call matrix transform
528 0 &_trans2;
529
530 # if input an array reference
531 ▶ } elsif (@_ == $h + 2 && ref($_[1]) eq 'ARRAY') {
Condition0%0/3
@_ == $h + 2 and ref $_[1] eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == $h + 2 and ref $_[1] eq "ARRAY"
@_ == $h + 2 ref $_[1] eq "ARRAY"
Truth table0%0/3
A and B
A= @_ == $h + 2B= ref $_[1] eq "ARRAY"
ABresult
0X0
100
111
532
533 # if array contains numbers (vector)
534 0 ▶ if (! ref($_[1][0]) && @{$_[1]} == grep {Scalar::Util::looks_like_number($_)} @{$_[1]}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})) { } 0 0 0
elsif (ref $_[1][0] eq 'ARRAY' and @{$_[1];} == grep({ref $_ eq 'ARRAY' and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})) { } 0 0 0
Condition0%0/3
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $_[1][0] and @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
not ref $_[1][0] @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
Truth table0%0/3
not(A) and B
A= not ref $_[1][0]B= @{$_[1];} == grep({&Scalar::Util::looks_like_number($_);} @{$_[1];})
ABresult
0X0
100
111
535
536 # call vector transform
537 0 &_trans1;
538
539 # if array contains vectors (2-D array)
540 0 ▶ } elsif (ref($_[1][0]) eq 'ARRAY' && @{$_[1]} == grep {ref($_) eq 'ARRAY' && Scalar::Util::looks_like_number($_->[0])} @{$_[1]}) {
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]) 0 0 0
Condition0%0/3
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[1][0] eq "ARRAY" and @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
ref $_[1][0] eq "ARRAY" @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
Truth table0%0/3
A and B
A= ref $_[1][0] eq "ARRAY"B= @{$_[1];} == grep({ref $_ eq "ARRAY" and &Scalar::Util::looks_like_number($_->[0]);} @{$_[1];})
ABresult
0X0
100
111
541
542 # call matrix transform
543 0 &_trans2;
544
545 } else {
546
547 # call structure transform
548 0 &_trans3;
549
550 }
551
552 # if input a list (of numbers)
553 0 } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) {
554
555 # call list transform
556 0 &_trans0;
557
558 } else {
559
560 # error
561 0 croak('invalid transform input');
562
563 }
564  
565 }
566  
567 # inverse transform
568 # note: number of undefined output values must equal number of defined input values
569 # note: the input and output vectors contain the final solution on return
570 # hash key 'init' specifies initial value vector
571 # hash key 'ubox' enables unit box extrapolation
572 # parameters: (input_vector, output_vector, [hash])
573 # returns: (RMS_error_value)
574 sub inverse {
575  
576 # get parameters
577 0 ▶ my ($self, $in, $out, $hash) = @_;
Subroutine inverse: not called CC=15 SCAR=54.8
Pod undocumented
578  
579 # local variables
580 0 my ($i, $j, @si, @so, $init);
581 0 my ($int, $jac, $mat, $delta);
582 0 my ($max, $elim, $dlim, $accum, $error);
583  
584 # initialize indices
585 0 $i = $j = -1;
586  
587 # build slice arrays while validating input and output arrays
588 0 ▶ ((grep {$i++; defined() && push(@si, $i)} @{$in}) == (grep {$j++; ! defined() && push(@so, $j)} @{$out})) or croak('wrong number of undefined values');
Branch: 3 branches
BranchTrueFalseTotal
grep({++$i; defined $_ and push @si, $i;} @{$in;}) == grep({++$j; not defined $_ and push @so, $j;} @{$out;}) or croak("wrong number of undefined values") 0 0 0
defined $_ and push @si, $i 0 0 0
not defined $_ and push @so, $j 0 0 0
589  
590 # get init array
591 0 $init = $hash->{'init'};
592  
593 # for each undefined output value
594 0 for my $i (@so) {
595
596 # set to supplied initial value or 0.5
597 0 ▶ $out->[$i] = defined($init->[$i]) ? $init->[$i] : 0.5;
Branch: 1 branch
BranchTrueFalseTotal
defined $init->[$i] ? : 0 0 0
598
599 }
600  
601 # set maximum loop count
602 0 ▶ $max = $hash->{'inv_max'} || 10;
Condition0%0/2
$hash->{'inv_max'} || 10
l!l
00
MC/DC0%0/1
$hash->{'inv_max'} || 10
$hash->{'inv_max'}
Truth table0%0/2
A
A= $hash->{'inv_max'}
Aresult
11
00
603  
604 # loop error limit
605 0 ▶ $elim = $hash->{'inv_elim'} || 1E-6;
Condition0%0/2
$hash->{'inv_elim'} || 1e-06
l!l
00
MC/DC0%0/1
$hash->{'inv_elim'} || 1e-06
$hash->{'inv_elim'}
Truth table0%0/2
A
A= $hash->{'inv_elim'}
Aresult
11
00
606  
607 # set delta limit
608 0 ▶ $dlim = $hash->{'inv_dlim'} || 0.5;
Condition0%0/2
$hash->{'inv_dlim'} || 0.5
l!l
00
MC/DC0%0/1
$hash->{'inv_dlim'} || 0.5
$hash->{'inv_dlim'}
Truth table0%0/2
A
A= $hash->{'inv_dlim'}
Aresult
11
00
609  
610 # create empty solution matrix
611 0 $mat = Math::Matrix->new([]);
612  
613 # compute initial transform values
614 0 ($jac, $int) = jacobian($self, $out, $hash);
615  
616 # solution loop
617 0 for (1 .. $max) {
618
619 # for each input
620 0 for my $i (0 .. $#si) {
621
622 # for each output
623 0 for my $j (0 .. $#so) {
624
625 # copy Jacobian value to solution matrix
626 0 $mat->[$i][$j] = $jac->[$si[$i]][$so[$j]];
627
628 }
629
630 # save residual value to solution matrix
631 0 $mat->[$i][$#si + 1] = $in->[$si[$i]] - $int->[$si[$i]];
632
633 }
634
635 # solve for delta values
636 0 $delta = $mat->solve;
637
638 # for each output value
639 0 for my $i (0 .. $#so) {
640
641 # add delta (limited using hyperbolic tangent)
642 0 $out->[$so[$i]] += POSIX::tanh($delta->[$i][0]/$dlim) * $dlim;
643
644 }
645
646 # compute updated transform values
647 0 ($jac, $int) = jacobian($self, $out, $hash);
648
649 # initialize error accumulator
650 0 $accum = 0;
651
652 # for each input
653 0 for my $i (0 .. $#si) {
654
655 # accumulate delta squared
656 0 $accum += ($in->[$si[$i]] - $int->[$si[$i]])**2;
657
658 }
659
660 # compute RMS error
661 0 $error = sqrt($accum/@si);
662
663 # if error less than limit
664 0 ▶ last if ($error < $elim);
Branch: 1 branch
BranchTrueFalseTotal
if $error < $elim 0 0 0
665
666 }
667  
668 # update input vector with final values
669 0 @{$in} = @{$int};
670  
671 # return
672 0 return($error);
673  
674 }
675  
676 # compute Jacobian matrix
677 # transform mask enables/disables individual tag elements
678 # parameters: (input_vector, [hash])
679 # returns: (Jacobian_matrix, [output_vector])
680 sub jacobian {
681  
682 # get parameters
683 0 ▶ my ($self, $data, $hash) = @_;
Subroutine jacobian: not called CC=7 SCAR=40.3
Pod undocumented
684  
685 # local variables
686 0 my ($jac, $jaci);
687  
688 # for each processing element
689 0 for my $i (0 .. $#{$self->[1]}) {
690
691 # if processing element defined, and transform mask bit set
692 0 ▶ if (defined($self->[1][$i]) && $self->[2] & 0x01 << $i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][$i] and $self->[2] & 1 << $i) 0 0 0
Condition0%0/3
defined $self->[1][$i] and $self->[2] & 1 << $i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->[1][$i] and $self->[2] & 1 << $i
defined $self->[1][$i] $self->[2] & 1 << $i
Truth table0%0/3
A and B
A= defined $self->[1][$i]B= $self->[2] & 1 << $i
ABresult
0X0
100
111
693
694 # compute Jacobian matrix and transform data
695 0 ($jaci, $data) = $self->[1][$i]->jacobian($data, $hash);
696
697 # multiply Jacobian matrices
698 0 ▶ $jac = defined($jac) ? $jaci * $jac : $jaci;
Branch: 1 branch
BranchTrueFalseTotal
defined $jac ? : 0 0 0
699
700 }
701
702 }
703  
704 # if Jacobian matrix is undefined, use identity matrix
705 0 ▶ $jac = Math::Matrix->diagonal((1) x @{$data}) if (! defined($jac));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $jac 0 0 0
706  
707 # if output values wanted
708 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
709
710 # return Jacobian and output values
711 0 return($jac, $data);
712
713 } else {
714
715 # return Jacobian only
716 0 return($jac);
717
718 }
719
720 }
721  
722 # get/set PCS encoding
723 # for use with ICC::Support::PCS objects
724 # parameters: ([PCS_encoding])
725 # returns: (PCS_encoding)
726 sub pcs {
727  
728 # get parameters
729 0 ▶ my ($self, $pcs) = @_;
Subroutine pcs: not called CC=4 SCAR=30.0
Pod undocumented
730  
731 # if PCS parameter is supplied
732 0 ▶ if (defined($pcs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pcs) { } 0 0 0
733
734 # if a valid PCS encoding
735 0 ▶ if (grep {$pcs == $_} (3, 8)) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$pcs == $_;} 3, 8) { } 0 0 0
736
737 # copy to tag header hash
738 0 $self->[0]{'pcs_encoding'} = $pcs;
739
740 # return PCS encoding
741 0 return($pcs);
742
743 } else {
744
745 # error
746 0 croak('invalid PCS encoding');
747
748 }
749
750 } else {
751
752 # if PCS is defined in tag header
753 0 ▶ if (defined($self->[0]{'pcs_encoding'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[0]{'pcs_encoding'}) { } 0 0 0
754
755 # return PCS encoding
756 0 return($self->[0]{'pcs_encoding'});
757
758 } else {
759
760 # error
761 0 croak('can\'t determine PCS encoding');
762
763 }
764
765 }
766
767 }
768  
769 # get/set white point
770 # parameters: ([white_point])
771 # returns: (white_point)
772 sub wtpt {
773  
774 # get parameters
775 0 ▶ my ($self, $wtpt) = @_;
Subroutine wtpt: not called CC=5 SCAR=34.0
Pod undocumented
776  
777 # if white point parameter is supplied
778 0 ▶ if (defined($wtpt)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wtpt) { } 0 0 0
779
780 # if an array of three scalars
781 0 ▶ if (@{$wtpt} == 3 && 3 == grep {! ref()} @{$wtpt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$wtpt;} == 3 and 3 == grep({not ref $_;} @{$wtpt;})) { } 0 0 0
Condition0%0/3
@{$wtpt;} == 3 and 3 == grep({not ref $_;} @{$wtpt;})
!ll&&!rl&&r
000
MC/DC0%0/2
@{$wtpt;} == 3 and 3 == grep({not ref $_;} @{$wtpt;})
@{$wtpt;} == 3 3 == grep({not ref $_;} @{$wtpt;})
Truth table0%0/3
A and B
A= @{$wtpt;} == 3B= 3 == grep({not ref $_;} @{$wtpt;})
ABresult
0X0
100
111
782
783 # copy to tag header hash
784 0 $self->[0]{'wtpt'} = $wtpt;
785
786 # return white point
787 0 return($wtpt);
788
789 } else {
790
791 # error
792 0 croak('invalid white point');
793
794 }
795
796 } else {
797
798 # if white point is defined in tag header
799 0 ▶ if (defined($self->[0]{'wtpt'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[0]{'wtpt'}) { } 0 0 0
800
801 # return return white point
802 0 return($self->[0]{'wtpt'});
803
804 } else {
805
806 # error
807 0 croak('can\'t determine white point');
808
809 }
810
811 }
812
813 }
814  
815 # print object contents to string
816 # format is an array structure
817 # parameter: ([format])
818 # returns: (string)
819 sub sdump {
820  
821 # get parameters
822 0 ▶ my ($self, $p) = @_;
Subroutine sdump: not called CC=11 SCAR=48.8
Pod documented
823  
824 # local variables
825 0 my ($element, $fmt, $s, $pt, $st);
826  
827 # resolve parameter to an array reference
828 0 ▶ $p = defined($p) ? ref($p) eq 'ARRAY' ? $p : [$p] : [];
Branch: 2 branches
BranchTrueFalseTotal
defined $p ? : 0 0 0
ref $p eq 'ARRAY' ? : 0 0 0
829  
830 # get format string
831 0 ▶ $fmt = defined($p->[0]) && ! ref($p->[0]) ? $p->[0] : 's';
Branch: 1 branch
BranchTrueFalseTotal
defined $p->[0] && !ref($p->[0]) ? : 0 0 0
Condition0%0/3
defined $p->[0] and not ref $p->[0]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->[0] and not ref $p->[0]
defined $p->[0] not ref $p->[0]
Truth table0%0/3
A and not(B)
A= defined $p->[0]B= not ref $p->[0]
ABresult
0X0
100
111
832  
833 # set string to object ID
834 0 $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self);
835  
836 # if format contains 'o'
837 0 ▶ if ($fmt =~ m/s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt =~ /s/) 0 0 0
838
839 # get default parameter
840 0 $pt = $p->[-1];
841
842 # for each processing element
843 0 for my $i (0 .. $#{$self->[1]}) {
844
845 # get element reference
846 0 $element = $self->[1][$i];
847
848 # if processing element is undefined
849 0 ▶ if (! defined($element)) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $element) { } 0 0 0
elsif (not builtin::blessed($element)) { } 0 0 0
elsif ($element->can('sdump')) { } 0 0 0
850
851 # append message
852 0 $s .= "\tprocessing element is undefined\n";
853
854 # if processing element is not a blessed object
855 } elsif (! Scalar::Util::blessed($element)) {
856
857 # append message
858 0 $s .= "\tprocessing element is not a blessed object\n";
859
860 # if processing element has an 'sdump' method
861 } elsif ($element->can('sdump')) {
862
863 # get 'sdump' string
864 0 ▶ $st = $element->sdump(defined($p->[$i + 1]) ? $p->[$i + 1] : $pt);
Branch: 1 branch
BranchTrueFalseTotal
defined $$p[$i + 1] ? : 0 0 0
865
866 # prepend tabs to each line
867 0 $st =~ s/^/\t/mg;
868
869 # append 'sdump' string
870 0 $s .= $st;
871
872 # processing element is object without an 'sdump' method
873 } else {
874
875 # append object info
876 0 $s .= sprintf("\t'%s' object, (0x%x)\n", ref($element), $element);
877
878 }
879
880 }
881
882 }
883  
884 # return
885 0 return($s);
886  
887 }
888  
889 # transform list
890 # parameters: (object_reference, list, [hash])
891 # returns: (list)
892 sub _trans0 {
893  
894 # local variables
895 0 ▶ my ($self, $hash, $data);
Subroutine _trans0: not called CC=2 SCAR=17.9
896  
897 # get object reference
898 0 $self = shift();
899  
900 # get optional hash
901 0 ▶ $hash = pop() if (ref($_[-1]) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "HASH" 0 0 0
902  
903 # process data
904 0 $data = _trans1($self, [@_], $hash);
905  
906 # return list
907 0 return(@{$data});
908  
909 }
910  
911 # transform vector
912 # parameters: (object_reference, vector, [hash])
913 # returns: (vector)
914 sub _trans1 {
915  
916 # get parameters
917 0 ▶ my ($self, $data, $hash) = @_;
Subroutine _trans1: not called CC=5 SCAR=34.0
918  
919 # for each processing element
920 0 for my $i (0 .. $#{$self->[1]}) {
921
922 # if processing element defined, and transform mask bit set
923 0 ▶ if (defined($self->[1][$i]) && $self->[2] & 0x01 << $i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][$i] and $self->[2] & 1 << $i) 0 0 0
Condition0%0/3
defined $self->[1][$i] and $self->[2] & 1 << $i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->[1][$i] and $self->[2] & 1 << $i
defined $self->[1][$i] $self->[2] & 1 << $i
Truth table0%0/3
A and B
A= defined $self->[1][$i]B= $self->[2] & 1 << $i
ABresult
0X0
100
111
924
925 # transform data
926 0 $data = $self->[1][$i]->_trans1($data, $hash);
927
928 # clip output values if clipping mask bit set
929 0 ▶ ICC::Shared::clip_struct($data) if ($self->[3] & 0x01 << $i);
Branch: 1 branch
BranchTrueFalseTotal
if $self->[3] & 1 << $i 0 0 0
930
931 }
932
933 }
934
935 # return
936 0 return($data);
937
938 }
939  
940 # transform matrix (2-D array -or- Math::Matrix object)
941 # parameters: (object_reference, matrix, [hash])
942 # returns: (matrix)
943 sub _trans2 {
944  
945 # get parameters
946 0 ▶ my ($self, $data, $hash) = @_;
Subroutine _trans2: not called CC=5 SCAR=34.0
947  
948 # for each processing element
949 0 for my $i (0 .. $#{$self->[1]}) {
950
951 # if processing element defined, and transform mask bit set
952 0 ▶ if (defined($self->[1][$i]) && $self->[2] & 0x01 << $i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][$i] and $self->[2] & 1 << $i) 0 0 0
Condition0%0/3
defined $self->[1][$i] and $self->[2] & 1 << $i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->[1][$i] and $self->[2] & 1 << $i
defined $self->[1][$i] $self->[2] & 1 << $i
Truth table0%0/3
A and B
A= defined $self->[1][$i]B= $self->[2] & 1 << $i
ABresult
0X0
100
111
953
954 # transform data
955 0 $data = $self->[1][$i]->_trans2($data, $hash);
956
957 # clip output values if clipping mask bit set
958 0 ▶ ICC::Shared::clip_struct($data) if ($self->[3] & 0x01 << $i);
Branch: 1 branch
BranchTrueFalseTotal
if $self->[3] & 1 << $i 0 0 0
959
960 }
961
962 }
963  
964 # return
965 0 return($data);
966  
967 }
968  
969 # transform structure
970 # parameters: (object_reference, structure, [hash])
971 # returns: (structure)
972 sub _trans3 {
973  
974 # get parameters
975 0 ▶ my ($self, $in, $hash) = @_;
Subroutine _trans3: not called CC=1 SCAR=6.9
976  
977 # transform the array structure
978 0 _crawl($self, $in, my $out = [], $hash);
979  
980 # return
981 0 return($out);
982  
983 }
984  
985 # recursive transform
986 # array structure is traversed until scalar arrays are found and transformed
987 # parameters: (ref_to_object, input_array_reference, output_array_reference, hash)
988 sub _crawl {
989  
990 # get parameters
991 0 ▶ my ($self, $in, $out, $hash) = @_;
Subroutine _crawl: not called CC=4 SCAR=30.0
992  
993 # if input is a vector (reference to a scalar array)
994 0 ▶ if (@{$in} == grep {! ref()} @{$in}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$in;} == grep({not ref $_;} @{$in;})) { } 0 0 0
995
996 # transform input vector and copy to output
997 0 @{$out} = @{_trans1($self, $in, $hash)};
998
999 } else {
1000
1001 # for each input element
1002 0 for my $i (0 .. $#{$in}) {
1003
1004 # if an array reference
1005 0 ▶ if (ref($in->[$i]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $in->[$i] eq 'ARRAY') { } 0 0 0
1006
1007 # transform next level
1008 0 _crawl($self, $in->[$i], $out->[$i] = [], $hash);
1009
1010 } else {
1011
1012 # error
1013 0 croak('invalid transform input');
1014
1015 }
1016
1017 }
1018
1019 }
1020
1021 }
1022  
1023 # check object structure
1024 # parameter: (ref_to_object)
1025 # returns: (number_input_channels, number_output_channels)
1026 sub _check {
1027  
1028 # get object reference
1029 1 ▶ my $self = shift();
Subroutine _check: called CC=22 SCAR=37.2
1030  
1031 # local variables
1032 1 my (@class, $ci, $co);
1033  
1034 # make object class array
1035 1 @class = qw(ICC::Profile::cvst ICC::Profile::matf ICC::Profile::cvst ICC::Profile::clut ICC::Profile::cvst);
1036  
1037 # verify number of processing elements
1038 1 ▶ ($#{$self->[1]} <= 4) or croak('\'mBA_\' object has too many processing elements');
Branch: 1 branch
BranchTrueFalseTotal
$#{$$self[1];} <= 4 or croak("'mBA_' object has too many processing elements") 0 1 1
1039  
1040 # for each processing element
1041 1 for my $i (0 .. $#{$self->[1]}) {
1042
1043 # if element is defined (matrix and M-curves to may be undefined)
1044 5 ▶ if (defined($self->[1][$i])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][$i]) 5 0 5
1045
1046 # verify element has correct class
1047 5 ▶ (ref($self->[1][$i]) eq $class[$i]) or croak("'mBA_' processing element $i has wrong class");
Branch: 1 branch
BranchTrueFalseTotal
ref $self->[1][$i] eq $class[$i] or croak("'mBA_' processing element $i has wrong class") 0 5 5
1048
1049 # if element has 'cin' method
1050 5 ▶ if ($self->[1][$i]->can('cin')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[1][$i]->can("cin")) 5 0 5
1051
1052 # if number of input channels is undefined
1053 5 ▶ if (! defined($ci)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ci) 1 4 5
1054
1055 # set number of input channels
1056 1 $ci = $self->[1][$i]->cin();
1057
1058 }
1059
1060 # if number of output channels is defined
1061 5 ▶ if (defined($co)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $co) 4 1 5
1062
1063 # verify input channels of this element match output channels of previous element
1064 4 ▶ ($self->[1][$i]->cin() == $co) or croak("'mBA_' processing element $i has wrong number of channels");
Branch: 1 branch
BranchTrueFalseTotal
$self->[1][$i]->cin == $co or croak("'mBA_' processing element $i has wrong number of channels") 0 4 4
1065
1066 }
1067
1068 }
1069
1070 # if element has 'cout' method
1071 5 ▶ if ($self->[1][$i]->can('cout')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[1][$i]->can("cout")) 5 0 5
1072
1073 # set number of output channels
1074 5 $co = $self->[1][$i]->cout();
1075
1076 }
1077
1078 }
1079
1080 }
1081  
1082 # verify B-curves are defined
1083 1 ▶ (defined($self->[1][0])) or croak('B-curves are required');
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[1][0] or croak("B-curves are required") 0 1 1
1084  
1085 # verify matrix and M-curves are both defined, or neither
1086 1 ▶ (defined($self->[1][1]) xor defined($self->[1][2])) && croak('matrix and M-curves must both be defined, or neither');
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[1][1] ^^ defined $self->[1][2] and croak("matrix and M-curves must both be defined, or neither") 0 1 1
Condition25%1/4
defined $self->[1][1] xor defined $self->[1][2]
l&&rl&&!r!l&&r!l&&!r
1000
MC/DC0%0/2
defined $self->[1][1] xor defined $self->[1][2]
defined $self->[1][1] defined $self->[1][2]
Truth table25%1/4
A xor B
A= defined $self->[1][1]B= defined $self->[1][2]
ABresult
110
101
011
000
1087  
1088 # verify CLUT and A-curves are both defined, or neither
1089 1 ▶ (defined($self->[1][3]) xor defined($self->[1][4])) && croak('CLUT and A-curves must both be defined, or neither');
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[1][3] ^^ defined $self->[1][4] and croak("CLUT and A-curves must both be defined, or neither") 0 1 1
Condition25%1/4
defined $self->[1][3] xor defined $self->[1][4]
l&&rl&&!r!l&&r!l&&!r
1000
MC/DC0%0/2
defined $self->[1][3] xor defined $self->[1][4]
defined $self->[1][3] defined $self->[1][4]
Truth table25%1/4
A xor B
A= defined $self->[1][3]B= defined $self->[1][4]
ABresult
110
101
011
000
1090  
1091 # if matrix defined
1092 1 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) 1 0 1
1093
1094 # verify object has 3 output channels
1095 1 ▶ ($ci == 3) or croak("matrix processing element not permitted with $ci input channels");
Branch: 1 branch
BranchTrueFalseTotal
$ci == 3 or croak("matrix processing element not permitted with $ci input channels") 0 1 1
1096
1097 # verify matrix size (3x3)
1098 1 ▶ ($self->[1][1]->cin() == 3 && $self->[1][1]->cout() == 3) or croak('matrix processing element matrix wrong size');
Branch: 1 branch
BranchTrueFalseTotal
$self->[1][1]->cin == 3 and $self->[1][1]->cout == 3 or croak("matrix processing element matrix wrong size") 0 1 1
Condition33%1/3
$self->[1][1]->cin == 3 and $self->[1][1]->cout == 3
!ll&&!rl&&r
001
MC/DC0%0/2
$self->[1][1]->cin == 3 and $self->[1][1]->cout == 3
$self->[1][1]->cin == 3 $self->[1][1]->cout == 3
Truth table33%1/3
A and B
A= $self->[1][1]->cin == 3B= $self->[1][1]->cout == 3
ABresult
0X0
100
111
1099
1100 # verify offset size (undefined, 0 or 3)
1101 1 ▶ (! defined($self->[1][1][2]) || @{$self->[1][1][2]} == 0 || @{$self->[1][1][2]} == 3) or croak('matrix processing element offset wrong size');
Branch: 1 branch
BranchTrueFalseTotal
not defined $self->[1][1][2] or @{$self->[1][1][2];} == 0 or @{$self->[1][1][2];} == 3 or croak("matrix processing element offset wrong size") 0 1 1
Condition33%2/6
not defined $self->[1][1][2] or @{$self->[1][1][2];} == 0 or @{$self->[1][1][2];} == 3
l!l&&r!l&&!r
010
not defined $self->[1][1][2] or @{$self->[1][1][2];} == 0
l!l&&r!l&&!r
001
MC/DC0%0/3
not defined $self->[1][1][2] or @{$self->[1][1][2];} == 0 or @{$self->[1][1][2];} == 3
not defined $self->[1][1][2] @{$self->[1][1][2];} == 0 @{$self->[1][1][2];} == 3
Truth table25%1/4
not(A) or B or C
A= not defined $self->[1][1][2]B= @{$self->[1][1][2];} == 0C= @{$self->[1][1][2];} == 3
ABCresult
1XX1
01X1
0011
0000
1102
1103 }
1104  
1105 # return
1106 1 return($ci, $co);
1107  
1108 }
1109  
1110 # set M-curves, matrix, and B-curves
1111 # equivalent to inverse of a matrix-based display profile
1112 # parameters: (ref_to_mAB_object, ref_to_profile_object)
1113 sub _newICCmatrix {
1114  
1115 # get parameters
1116 0 ▶ my ($self, $disp) = @_;
Subroutine _newICCmatrix: not called CC=9 SCAR=45.0
1117  
1118 # local variables
1119 0 my (@XYZ, @TRC, $wtpt, $bkpt, $id, $mat);
1120  
1121 # verify an RGB/XYZ display profile
1122 0 ▶ (UNIVERSAL::isa($disp, 'ICC::Profile') && $disp->profile_header->[3] eq 'mntr' && $disp->profile_header->[4] eq 'RGB ' && $disp->profile_header->[5] eq 'XYZ ') or croak('not an RGB-XYZ display profile');
Branch: 1 branch
BranchTrueFalseTotal
UNIVERSAL::isa($disp, "ICC::Profile") and $disp->profile_header->[3] eq "mntr" and $disp->profile_header->[4] eq "RGB " and $disp->profile_header->[5] eq "XYZ " or croak("not an RGB-XYZ display profile") 0 0 0
Condition0%0/9
UNIVERSAL::isa($disp, "ICC::Profile") and $disp->profile_header->[3] eq "mntr" and $disp->profile_header->[4] eq "RGB " and $disp->profile_header->[5] eq "XYZ "
!ll&&!rl&&r
000
UNIVERSAL::isa($disp, "ICC::Profile") and $disp->profile_header->[3] eq "mntr" and $disp->profile_header->[4] eq "RGB "
!ll&&!rl&&r
000
UNIVERSAL::isa($disp, "ICC::Profile") and $disp->profile_header->[3] eq "mntr"
!ll&&!rl&&r
000
MC/DC0%0/4
UNIVERSAL::isa($disp, "ICC::Profile") and $disp->profile_header->[3] eq "mntr" and $disp->profile_header->[4] eq "RGB " and $disp->profile_header->[5] eq "XYZ "
UNIVERSAL::isa($disp, "ICC::Profile") $disp->profile_header->[3] eq "mntr" $disp->profile_header->[4] eq "RGB " $disp->profile_header->[5] eq "XYZ "
Truth table0%0/5
A and B and C and D
A= UNIVERSAL::isa($disp, "ICC::Profile")B= $disp->profile_header->[3] eq "mntr"C= $disp->profile_header->[4] eq "RGB "D= $disp->profile_header->[5] eq "XYZ "
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1123  
1124 # get primary tags
1125 0 @XYZ = $disp->tag(qw(rXYZ gXYZ bXYZ));
1126  
1127 # get TRC tags
1128 0 @TRC = $disp->tag(qw(rTRC gTRC bTRC));
1129  
1130 # verify a matrix profile
1131 0 ▶ (@XYZ == 3 && @TRC == 3) or croak('not a matrix profile');
Branch: 1 branch
BranchTrueFalseTotal
@XYZ == 3 and @TRC == 3 or croak("not a matrix profile") 0 0 0
Condition0%0/3
@XYZ == 3 and @TRC == 3
!ll&&!rl&&r
000
MC/DC0%0/2
@XYZ == 3 and @TRC == 3
@XYZ == 3 @TRC == 3
Truth table0%0/3
A and B
A= @XYZ == 3B= @TRC == 3
ABresult
0X0
100
111
1132  
1133 # set input colorspace
1134 0 $self->[0]{'input_cs'} = 'XYZ ';
1135  
1136 # set output colorspace
1137 0 $self->[0]{'output_cs'} = 'RGB ';
1138  
1139 # set PCS encoding
1140 0 $self->[0]{'pcs_encoding'} = 7;
1141  
1142 # get white point tag
1143 0 $wtpt = $disp->tag('wtpt');
1144  
1145 # set white point value
1146 0 ▶ $self->[0]{'wtpt'} = [@{$wtpt->XYZ}] if (defined($wtpt));
Branch: 1 branch
BranchTrueFalseTotal
if defined $wtpt 0 0 0
1147  
1148 # get black point tag
1149 0 $bkpt = $disp->tag('bkpt');
1150  
1151 # set black point value
1152 0 ▶ $self->[0]{'bkpt'} = [@{$bkpt->XYZ}] if (defined($bkpt));
Branch: 1 branch
BranchTrueFalseTotal
if defined $bkpt 0 0 0
1153  
1154 # make identity curve
1155 0 $id = ICC::Profile::curv->new();
1156  
1157 # make Math::Matrix object from primary tags (inverse)
1158 0 $mat = Math::Matrix->new(map {$_->XYZ()} @XYZ)->transpose->invert->multiply_scalar(65535/32768);
1159  
1160 # set B-curves
1161 0 $self->[1][0] = ICC::Profile::cvst->new([$id, $id, $id]);
1162  
1163 # set matrix (inverse)
1164 0 $self->[1][1] = ICC::Profile::matf->new({'matrix' => $mat});
1165  
1166 # set M-curves (inverse)
1167 0 $self->[1][2] = ICC::Profile::cvst->new([map {$_->inv()} @TRC]);
1168  
1169 # set transform mask
1170 0 $self->[2] = 0x07;
1171  
1172 }
1173  
1174 # make new mBA_ tag from attribute hash
1175 # hash may contain pointers to B-curves, matrix, M-curves, CLUT, or A-curves
1176 # keys are: ('b_curves', 'matrix', 'm_curves', 'clut', 'a_curves')
1177 # tag elements not specified in the hash are left empty
1178 # parameters: (ref_to_object, ref_to_attribute_hash)
1179 sub _new_from_hash {
1180  
1181 # get parameters
1182 0 ▶ my ($self, $hash) = @_;
Subroutine _new_from_hash: not called CC=4 SCAR=30.0
1183  
1184 # set attribute list (key => [reference_type, array_index])
1185 0 my %list = ('b_curves' => ['ICC::Profile::cvst', 0], 'matrix' => ['ICC::Profile::matf', 1], 'm_curves' => ['ICC::Profile::cvst', 2], 'clut' => ['ICC::Profile::clut', 3], 'a_curves' => ['ICC::Profile::cvst', 4]);
1186  
1187 # for each attribute
1188 0 for my $attr (keys(%{$hash})) {
1189
1190 # if value defined
1191 0 ▶ if (defined($hash->{$attr})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash->{$attr}) 0 0 0
1192
1193 # if correct reference type
1194 0 ▶ if (ref($hash->{$attr}) eq $list{$attr}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash->{$attr} eq $list{$attr}[0]) { } 0 0 0
1195
1196 # set tag element
1197 0 $self->[1][$list{$attr}[1]] = $hash->{$attr};
1198
1199 # set transform mask bit
1200 0 $self->[2] |= (0x01 << $list{$attr}[1]);
1201
1202 } else {
1203
1204 # error
1205 0 croak("wrong object type for $attr key");
1206
1207 }
1208
1209 }
1210
1211 }
1212
1213 }
1214  
1215 # read mBA_ tag from ICC profile
1216 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
1217 sub _readICCmBA_ {
1218  
1219 # get parameters
1220 1 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _readICCmBA_: called CC=20 SCAR=31.7
1221  
1222 # local variables
1223 1 my ($buf, @mft, $pel, $mark, @mat, $bytes, $gsa);
1224  
1225 # set tag signature
1226 1 $self->[0]{'signature'} = $tag->[0];
1227  
1228 # set input colorspace
1229 1 $self->[0]{'input_cs'} = $parent->[1][5];
1230  
1231 # set output colorspace
1232 1 $self->[0]{'output_cs'} = $parent->[1][4];
1233  
1234 # seek start of tag
1235 1 seek($fh, $tag->[1], 0);
1236  
1237 # read tag header
1238 1 read($fh, $buf, 32);
1239  
1240 # unpack header
1241 1 @mft = unpack('a4 x4 C2 x2 N5', $buf);
1242  
1243 # verify tag signature
1244 1 ▶ ($mft[0] eq 'mBA ') or croak('wrong tag type');
Branch: 1 branch
BranchTrueFalseTotal
$mft[0] eq "mBA " or croak("wrong tag type") 0 1 1
1245  
1246 # verify number input channels (1 to 15)
1247 1 ▶ ($mft[1] > 0 && $mft[1] < 16) or croak('unsupported number of input channels');
Branch: 1 branch
BranchTrueFalseTotal
$mft[1] > 0 and $mft[1] < 16 or croak("unsupported number of input channels") 0 1 1
Condition33%1/3
$mft[1] > 0 and $mft[1] < 16
!ll&&!rl&&r
001
MC/DC0%0/2
$mft[1] > 0 and $mft[1] < 16
$mft[1] > 0 $mft[1] < 16
Truth table33%1/3
A and B
A= $mft[1] > 0B= $mft[1] < 16
ABresult
0X0
100
111
1248  
1249 # verify number output channels (1 to 15)
1250 1 ▶ ($mft[2] > 0 && $mft[2] < 16) or croak('unsupported number of output channels');
Branch: 1 branch
BranchTrueFalseTotal
$mft[2] > 0 and $mft[2] < 16 or croak("unsupported number of output channels") 0 1 1
Condition33%1/3
$mft[2] > 0 and $mft[2] < 16
!ll&&!rl&&r
001
MC/DC0%0/2
$mft[2] > 0 and $mft[2] < 16
$mft[2] > 0 $mft[2] < 16
Truth table33%1/3
A and B
A= $mft[2] > 0B= $mft[2] < 16
ABresult
0X0
100
111
1251  
1252 # if B-curves are defined
1253 1 ▶ if ($mft[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[3]) 1 0 1
1254
1255 # make 'cvst' object for B-curves
1256 1 $pel = ICC::Profile::cvst->new();
1257
1258 # set file pointer to start of first B-curve
1259 1 $mark = $tag->[1] + $mft[3];
1260
1261 # for each input channel
1262 1 for my $i (0 .. $mft[1] - 1) {
1263
1264 # adjust file pointer to 4-byte boundary
1265 3 $mark += (-$mark % 4);
1266
1267 # seek to start of curve
1268 3 seek($fh, $mark, 0);
1269
1270 # read curve type
1271 3 read($fh, $buf, 4);
1272
1273 # if 'curv' type
1274 3 ▶ if ($buf eq 'curv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($buf eq 'curv') { } 0 3 3
elsif ($buf eq 'para') { } 3 0 3
1275
1276 # parse 'curv' object
1277 0 $pel->[1][$i] = ICC::Profile::curv->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1278
1279 } elsif ($buf eq 'para') {
1280
1281 # parse 'para' object
1282 3 $pel->[1][$i] = ICC::Profile::para->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1283
1284 } else {
1285
1286 # error
1287 0 croak('unsupported curve type or invalid tag structure');
1288
1289 }
1290
1291 # mark current file pointer location
1292 3 $mark = tell($fh);
1293
1294 }
1295
1296 # set signature
1297 1 $pel->[0]{'signature'} = 'mBA_';
1298
1299 # add processing element
1300 1 $self->[1][0] = $pel;
1301
1302 # set transform mask
1303 1 $self->[2] |= 0x01;
1304
1305 }
1306  
1307 # if matrix is defined
1308 1 ▶ if ($mft[4]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[4]) 1 0 1
1309
1310 # make 'matf' object for matrix
1311 1 $pel = ICC::Profile::matf->new();
1312
1313 # seek to start of matrix
1314 1 seek($fh, $tag->[1] + $mft[4], 0);
1315
1316 # read matrix
1317 1 $pel->_read_matf($fh, 3, 3, 1, 2);
1318
1319 # set signature
1320 1 $pel->[0]{'signature'} = 'mBA_';
1321
1322 # add processing element
1323 1 $self->[1][1] = $pel;
1324
1325 # set transform mask
1326 1 $self->[2] |= 0x02;
1327
1328 }
1329  
1330 # if M-curves are defined
1331 1 ▶ if ($mft[5]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[5]) 1 0 1
1332
1333 # make 'cvst' object for M-curves
1334 1 $pel = ICC::Profile::cvst->new();
1335
1336 # set file pointer to start of first M-curve
1337 1 $mark = $tag->[1] + $mft[5];
1338
1339 # for each input channel
1340 1 for my $i (0 .. $mft[1] - 1) {
1341
1342 # adjust file pointer to 4-byte boundary
1343 3 $mark += (-$mark % 4);
1344
1345 # seek to start of curve
1346 3 seek($fh, $mark, 0);
1347
1348 # read curve type
1349 3 read($fh, $buf, 4);
1350
1351 # if 'curv' type
1352 3 ▶ if ($buf eq 'curv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($buf eq 'curv') { } 0 3 3
elsif ($buf eq 'para') { } 3 0 3
1353
1354 # parse 'curv' object
1355 0 $pel->[1][$i] = ICC::Profile::curv->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1356
1357 } elsif ($buf eq 'para') {
1358
1359 # parse 'para' object
1360 3 $pel->[1][$i] = ICC::Profile::para->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1361
1362 } else {
1363
1364 # error
1365 0 croak('unsupported curve type or invalid tag structure');
1366
1367 }
1368
1369 # mark current file pointer location
1370 3 $mark = tell($fh);
1371
1372 }
1373
1374 # set signature
1375 1 $pel->[0]{'signature'} = 'mBA_';
1376
1377 # add processing element
1378 1 $self->[1][2] = $pel;
1379
1380 # set transform mask
1381 1 $self->[2] |= 0x04;
1382
1383 }
1384  
1385 # if CLUT defined
1386 1 ▶ if ($mft[6]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[6]) 1 0 1
1387
1388 # make 'clut' object for CLUT
1389 1 $pel = ICC::Profile::clut->new();
1390
1391 # seek to start of CLUT
1392 1 seek($fh, $tag->[1] + $mft[6], 0);
1393
1394 # read header
1395 1 read($fh, $buf, 20);
1396
1397 # unpack header
1398 1 @mat = unpack('C17', $buf);
1399
1400 # get CLUT byte width
1401 1 $bytes = pop(@mat);
1402
1403 # save CLUT byte width
1404 1 $pel->[0]{'clut_bytes'} = $bytes;
1405
1406 # set number of input channels
1407 1 $pel->[0]{'input_channels'} = $mft[1];
1408  
1409 # set number of output channels
1410 1 $pel->[0]{'output_channels'} = $mft[2];
1411  
1412 # make grid size array
1413 1 $gsa = [grep {$_} @mat];
1414
1415 # read 'clut' data
1416 1 $pel->_read_clut($fh, $mft[2], $gsa, $bytes);
1417
1418 # save grid size array
1419 1 $pel->[2] = [@{$gsa}];
1420
1421 # set signature
1422 1 $pel->[0]{'signature'} = 'mBA_';
1423
1424 # add processing element
1425 1 $self->[1][3] = $pel;
1426
1427 # set transform mask
1428 1 $self->[2] |= 0x08;
1429
1430 }
1431  
1432 # if A-curves are defined
1433 1 ▶ if ($mft[7]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[7]) 1 0 1
1434
1435 # make 'cvst' object for A-curves
1436 1 $pel = ICC::Profile::cvst->new();
1437
1438 # set file pointer to start of first A-curve
1439 1 $mark = $tag->[1] + $mft[7];
1440
1441 # for each output channel
1442 1 for my $i (0 .. $mft[2] - 1) {
1443
1444 # adjust file pointer to 4-byte boundary
1445 3 $mark += (-$mark % 4);
1446
1447 # seek to start of curve
1448 3 seek($fh, $mark, 0);
1449
1450 # read curve type
1451 3 read($fh, $buf, 4);
1452
1453 # if 'curv' type
1454 3 ▶ if ($buf eq 'curv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($buf eq 'curv') { } 0 3 3
elsif ($buf eq 'para') { } 3 0 3
1455
1456 # parse 'curv' object
1457 0 $pel->[1][$i] = ICC::Profile::curv->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1458
1459 } elsif ($buf eq 'para') {
1460
1461 # parse 'para' object
1462 3 $pel->[1][$i] = ICC::Profile::para->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1463
1464 } else {
1465
1466 # error
1467 0 croak('unsupported curve type or invalid tag structure');
1468
1469 }
1470
1471 # mark current file pointer location
1472 3 $mark = tell($fh);
1473
1474 }
1475
1476 # set signature
1477 1 $pel->[0]{'signature'} = 'mBA_';
1478
1479 # add processing element
1480 1 $self->[1][4] = $pel;
1481
1482 # set transform mask
1483 1 $self->[2] |= 0x10;
1484
1485 }
1486  
1487 }
1488  
1489 # write mBA_ tag to ICC profile
1490 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
1491 sub _writeICCmBA_ {
1492  
1493 # get parameters
1494 1 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _writeICCmBA_: called CC=20 SCAR=31.3
1495  
1496 # local variables
1497 1 my (@mft, $offset, @mat, $bytes, $size);
1498  
1499 # set tag type
1500 1 $mft[0] = 'mBA ';
1501  
1502 # check object structure
1503 1 @mft[1, 2] = _check($self);
1504  
1505 # initialize offset
1506 1 $offset = 32;
1507  
1508 # set offset to B-curves
1509 1 $mft[3] = 32;
1510  
1511 # if B-curves defined
1512 1 ▶ if (defined($self->[1][0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][0]) { } 1 0 1
1513
1514 # for each B-curve
1515 1 for my $curve (@{$self->[1][0]->array()}) {
1516
1517 # add curve size
1518 3 $offset += $curve->size;
1519
1520 # pad to 4-bytes
1521 3 $offset += (-$offset % 4);
1522
1523 }
1524
1525 } else {
1526
1527 # error
1528 0 croak('B-curves are required');
1529
1530 }
1531  
1532 # if matrix is defined
1533 1 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) { } 1 0 1
1534
1535 # verify output channels
1536 1 ▶ ($mft[2] == 3) or croak('3 output channels required for matrix');
Branch: 1 branch
BranchTrueFalseTotal
$mft[2] == 3 or croak("3 output channels required for matrix") 0 1 1
1537
1538 # set offset
1539 1 $mft[4] = $offset;
1540
1541 # increment offset for matrix size
1542 1 $offset += 48;
1543
1544 } else {
1545
1546 # set offset
1547 0 $mft[4] = 0;
1548
1549 }
1550  
1551 # if M-curves defined
1552 1 ▶ if (defined($self->[1][2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][2]) { } 1 0 1
1553
1554 # verify output channels
1555 1 ▶ ($mft[2] == 3) or croak('3 output channels required for M-curves');
Branch: 1 branch
BranchTrueFalseTotal
$mft[2] == 3 or croak("3 output channels required for M-curves") 0 1 1
1556
1557 # set offset
1558 1 $mft[5] = $offset;
1559
1560 # for each M-curve
1561 1 for my $curve (@{$self->[1][2]->array()}) {
1562
1563 # add curve size
1564 3 $offset += $curve->size;
1565
1566 # pad to 4-bytes
1567 3 $offset += (-$offset % 4);
1568
1569 }
1570
1571 } else {
1572
1573 # set offset
1574 0 $mft[5] = 0;
1575
1576 }
1577  
1578 # if CLUT defined
1579 1 ▶ if (defined($self->[1][3])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][3]) { } 1 0 1
1580
1581 # set offset
1582 1 $mft[6] = $offset;
1583
1584 # get CLUT data size
1585 1 ▶ $bytes = $self->[1][3][0]{'clut_bytes'} || 2;
Condition50%1/2
$self->[1][3][0]{'clut_bytes'} || 2
l!l
10
MC/DC0%0/1
$self->[1][3][0]{'clut_bytes'} || 2
$self->[1][3][0]{'clut_bytes'}
Truth table50%1/2
A
A= $self->[1][3][0]{'clut_bytes'}
Aresult
11
00
1586
1587 # add CLUT size to offset
1588 1 $offset += 20 + $self->[1][3]->_clut_size($bytes);
1589
1590 # pad to 4-byte boundary
1591 1 $offset += (-$offset % 4);
1592
1593 } else {
1594
1595 # set offset
1596 0 $mft[6] = 0;
1597
1598 }
1599  
1600 # if A-curves defined
1601 1 ▶ if (defined($self->[1][4])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][4]) { } 1 0 1
1602
1603 # set offset
1604 1 $mft[7] = $offset;
1605
1606 } else {
1607
1608 # set offset
1609 0 $mft[7] = 0;
1610
1611 }
1612  
1613 # seek start of tag
1614 1 seek($fh, $tag->[1], 0);
1615  
1616 # write header
1617 1 print $fh pack('a4 x4 C2 x2 N5', @mft);
1618  
1619 # seek start of B-curves
1620 1 seek($fh, $tag->[1] + $mft[3], 0);
1621  
1622 # for each B-curve
1623 1 for my $curve (@{$self->[1][0]->array()}) {
1624
1625 # write curve object
1626 3 $curve->write_fh($self->[1][0], $fh, ['cvst', tell($fh), 0, 0]);
1627
1628 # add padding to 4-byte boundary
1629 3 seek($fh, (-tell($fh) % 4), 1);
1630
1631 }
1632  
1633 # if matrix is defined
1634 1 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) 1 0 1
1635
1636 # seek start of matrix
1637 1 seek($fh, $tag->[1] + $mft[4], 0);
1638
1639 # write matrix
1640 1 $self->[1][1]->_write_matf($fh, 1, 2);
1641
1642 }
1643  
1644 # if M-curves are defined
1645 1 ▶ if (defined($self->[1][2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][2]) 1 0 1
1646
1647 # seek start of M-curves
1648 1 seek($fh, $tag->[1] + $mft[5], 0);
1649
1650 # for each M-curve
1651 1 for my $curve (@{$self->[1][2]->array()}) {
1652
1653 # write curve object
1654 3 $curve->write_fh($self->[1][2], $fh, ['cvst', tell($fh), 0, 0]);
1655
1656 # add padding to 4-byte boundary
1657 3 seek($fh, (-tell($fh) % 4), 1);
1658
1659 }
1660
1661 }
1662  
1663 # if CLUT is defined
1664 1 ▶ if (defined($self->[1][3])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][3]) 1 0 1
1665
1666 # for each possible input channel
1667 1 for my $i (0 .. 15) {
1668
1669 # set grid size
1670 16 ▶ $mat[$i] = $self->[1][3]->gsa->[$i] || 0;
Condition100%2/2
$self->[1][3]->gsa->[$i] || 0
l!l
313
MC/DC100%1/1
$self->[1][3]->gsa->[$i] || 0
$self->[1][3]->gsa->[$i]
Truth table100%2/2
A
A= $self->[1][3]->gsa->[$i]
Aresult
11
00
1671
1672 }
1673
1674 # set CLUT byte width
1675 1 $mat[16] = $bytes;
1676
1677 # seek start of CLUT
1678 1 seek($fh, $tag->[1] + $mft[6], 0);
1679
1680 # write CLUT header
1681 1 print $fh pack('C17 x3', @mat);
1682
1683 # write CLUT
1684 1 $self->[1][3]->_write_clut($fh, $self->[1][3]->gsa(), $bytes);
1685
1686 }
1687  
1688 # if A-curves are defined
1689 1 ▶ if (defined($self->[1][4])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][4]) 1 0 1
1690
1691 # seek start of A-curves
1692 1 seek($fh, $tag->[1] + $mft[7], 0);
1693
1694 # for each M-curve
1695 1 for my $curve (@{$self->[1][4]->array()}) {
1696
1697 # write curve object
1698 3 $curve->write_fh($self->[1][4], $fh, ['cvst', tell($fh), 0, 0]);
1699
1700 # add padding to 4-byte boundary
1701 3 seek($fh, (-tell($fh) % 4), 1);
1702
1703 }
1704
1705 }
1706
1707 }
1708  
1709 2 1;
« blib/lib/ICC/Support/Color.pm ↑ Summary blib/lib/ICC/Support/nNET.pm »