lib/ICC/Profile/mAB_.pm

filter: Statementstmt 45.7% 212 / 463 Branchbran 21.8% 48 / 220 Conditioncond 11.2% 11 / 98 MC/DCmcdc 1.6% 1 / 59 Subroutinesub 33.3% 12 / 36 Podpod 4.7% 1 / 21 totaltotal 31.7% 285 / 897 CC 170 SCAR 40.3
CC
170
Cov
35%
inverse
240.0
transform
156.0
sdump
132.0
CRAP 56.0
« lib/ICC/Support/geo1.pm ↑ Summary lib/ICC/Profile/mBA_.pm »
1 package ICC::Profile::mAB_;
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 2016-05-17
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 mAB_ 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 mAB_ 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 mAB_ 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') || 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 undocumented
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 mAB_ 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 mAB_ 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) || croak('wrong number of parameters');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("wrong number of parameters") 0 1 1
381  
382 # read mAB_ data from profile
383 1 _readICCmAB_($self, @_);
384  
385 # bless object
386 1 bless($self, $class);
387  
388 # return object reference
389 1 return($self);
390  
391 }
392  
393 # writes mAB_ tag object to ICC profile
394 # parameters: (ref_to_parent_object, file_handle, ref_to_tag_table_entry)
395 sub write_fh {
396  
397 # get tag reference
398 1 ▶ my $self = shift();
Subroutine write_fh: called CC=2 SCAR=7.1
Pod undocumented
399  
400 # verify 3 parameters
401 1 ▶ (@_ == 3) || croak('wrong number of parameters');
Branch: 1 branch
BranchTrueFalseTotal
@_ == 3 or croak("wrong number of parameters") 0 1 1
402  
403 # write mAB_ data to profile
404 1 _writeICCmAB_($self, @_);
405  
406 }
407  
408 # get tag size (for writing to profile)
409 # returns: (tag_clut_size)
410 sub size {
411  
412 # get parameters
413 3 ▶ my ($self) = @_;
Subroutine size: called CC=9 SCAR=22.3
Pod undocumented
414  
415 # local variables
416 3 my ($size);
417  
418 # set header size
419 3 $size = 32;
420  
421 # for each B-curve
422 3 for my $curve (@{$self->[1][0]->array()}) {
423
424 # add curve size
425 9 $size += $curve->size;
426
427 # pad to 4-bytes
428 9 $size += (-$size % 4);
429
430 }
431  
432 # if matrix defined
433 3 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) 3 0 3
434
435 # add matrix size (48 bytes)
436 3 $size += 48;
437
438 }
439  
440 # if M-curves defined
441 3 ▶ if (defined($self->[1][2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][2]) 3 0 3
442
443 # for each M-curve
444 3 for my $curve (@{$self->[1][2]->array()}) {
445
446 # add curve size
447 9 $size += $curve->size;
448
449 # pad to 4-bytes
450 9 $size += (-$size % 4);
451
452 }
453
454 }
455  
456 # if CLUT defined
457 3 ▶ if (defined($self->[1][3])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][3]) 3 0 3
458
459 # add CLUT size (nCLUT object)
460 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
461
462 # pad to 4-byte boundary
463 3 $size += (-$size % 4);
464
465 }
466  
467 # if A-curves defined
468 3 ▶ if (defined($self->[1][4])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][4]) 3 0 3
469
470 # for each A-curve
471 3 for my $curve (@{$self->[1][4]->array()}) {
472
473 # add curve size
474 9 $size += $curve->size;
475
476 # pad to 4-bytes
477 9 $size += (-$size % 4);
478
479 }
480
481 }
482  
483 # return size
484 3 return($size);
485  
486 }
487  
488 # get number of input channels
489 # returns: (number)
490 sub cin {
491  
492 # get object reference
493 0 ▶ my $self = shift();
Subroutine cin: not called CC=1 SCAR=6.9
Pod undocumented
494  
495 # return
496 0 return($self->[1][-1]->cin());
497  
498 }
499  
500 # get number of output channels
501 # returns: (number)
502 sub cout {
503  
504 # get object reference
505 0 ▶ my $self = shift();
Subroutine cout: not called CC=1 SCAR=6.9
Pod undocumented
506  
507 # return
508 0 return($self->[1][0]->cout());
509  
510 }
511  
512 # transform data
513 # transform mask enables/disables individual tag elements
514 # clipping mask enables/disables individual tag output clipping
515 # supported input types:
516 # parameters: (list, [hash])
517 # parameters: (vector, [hash])
518 # parameters: (matrix, [hash])
519 # parameters: (Math::Matrix_object, [hash])
520 # parameters: (structure, [hash])
521 # returns: (same_type_as_input)
522 sub transform {
523  
524 # set hash value (0 or 1)
525 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
526  
527 # if input a 'Math::Matrix' object
528 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
529
530 # call matrix transform
531 0 &_trans2;
532
533 # if input an array reference
534 ▶ } 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
535
536 # if array contains numbers (vector)
537 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
538
539 # call vector transform
540 0 &_trans1;
541
542 # if array contains vectors (2-D array)
543 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
544
545 # call matrix transform
546 0 &_trans2;
547
548 } else {
549
550 # call structure transform
551 0 &_trans3;
552
553 }
554
555 # if input a list (of numbers)
556 0 } elsif (@_ == $h + 1 + grep {Scalar::Util::looks_like_number($_)} @_) {
557
558 # call list transform
559 0 &_trans0;
560
561 } else {
562
563 # error
564 0 croak('invalid transform input');
565
566 }
567  
568 }
569  
570 # inverse transform
571 # note: number of undefined output values must equal number of defined input values
572 # note: the input and output vectors contain the final solution on return
573 # hash key 'init' specifies initial value vector
574 # hash key 'ubox' enables unit box extrapolation
575 # parameters: (input_vector, output_vector, [hash])
576 # returns: (RMS_error_value)
577 sub inverse {
578  
579 # get parameters
580 0 ▶ my ($self, $in, $out, $hash) = @_;
Subroutine inverse: not called CC=15 SCAR=54.8
Pod undocumented
581  
582 # local variables
583 0 my ($i, $j, @si, @so, $init);
584 0 my ($int, $jac, $mat, $delta);
585 0 my ($max, $elim, $dlim, $accum, $error);
586  
587 # initialize indices
588 0 $i = $j = -1;
589  
590 # build slice arrays while validating input and output arrays
591 0 ▶ ((grep {$i++; defined() && push(@si, $i)} @{$in}) == (grep {$j++; ! defined() && push(@so, $j)} @{$out})) || 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
592  
593 # get init array
594 0 $init = $hash->{'init'};
595  
596 # for each undefined output value
597 0 for my $i (@so) {
598
599 # set to supplied initial value or 0.5
600 0 ▶ $out->[$i] = defined($init->[$i]) ? $init->[$i] : 0.5;
Branch: 1 branch
BranchTrueFalseTotal
defined $init->[$i] ? : 0 0 0
601
602 }
603  
604 # set maximum loop count
605 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
606  
607 # loop error limit
608 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
609  
610 # set delta limit
611 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
612  
613 # create empty solution matrix
614 0 $mat = Math::Matrix->new([]);
615  
616 # compute initial transform values
617 0 ($jac, $int) = jacobian($self, $out, $hash);
618  
619 # solution loop
620 0 for (1 .. $max) {
621
622 # for each input
623 0 for my $i (0 .. $#si) {
624
625 # for each output
626 0 for my $j (0 .. $#so) {
627
628 # copy Jacobian value to solution matrix
629 0 $mat->[$i][$j] = $jac->[$si[$i]][$so[$j]];
630
631 }
632
633 # save residual value to solution matrix
634 0 $mat->[$i][$#si + 1] = $in->[$si[$i]] - $int->[$si[$i]];
635
636 }
637
638 # solve for delta values
639 0 $delta = $mat->solve;
640
641 # for each output value
642 0 for my $i (0 .. $#so) {
643
644 # add delta (limited using hyperbolic tangent)
645 0 $out->[$so[$i]] += POSIX::tanh($delta->[$i][0]/$dlim) * $dlim;
646
647 }
648
649 # compute updated transform values
650 0 ($jac, $int) = jacobian($self, $out, $hash);
651
652 # initialize error accumulator
653 0 $accum = 0;
654
655 # for each input
656 0 for my $i (0 .. $#si) {
657
658 # accumulate delta squared
659 0 $accum += ($in->[$si[$i]] - $int->[$si[$i]])**2;
660
661 }
662
663 # compute RMS error
664 0 $error = sqrt($accum/@si);
665
666 # if error less than limit
667 0 ▶ last if ($error < $elim);
Branch: 1 branch
BranchTrueFalseTotal
if $error < $elim 0 0 0
668
669 }
670  
671 # update input vector with final values
672 0 @{$in} = @{$int};
673  
674 # return
675 0 return($error);
676  
677 }
678  
679 # compute Jacobian matrix
680 # transform mask enables/disables individual tag elements
681 # parameters: (input_vector, [hash])
682 # returns: (Jacobian_matrix, [output_vector])
683 sub jacobian {
684  
685 # get parameters
686 0 ▶ my ($self, $data, $hash) = @_;
Subroutine jacobian: not called CC=7 SCAR=40.3
Pod undocumented
687  
688 # local variables
689 0 my ($jac, $jaci);
690  
691 # for each processing element (note: sequence is from the last element to the first)
692 0 for my $i (reverse(0 .. $#{$self->[1]})) {
693
694 # if processing element defined, and transform mask bit set
695 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
696
697 # compute Jacobian matrix and transform data
698 0 ($jaci, $data) = $self->[1][$i]->jacobian($data, $hash);
699
700 # multiply Jacobian matrices
701 0 ▶ $jac = defined($jac) ? $jaci * $jac : $jaci;
Branch: 1 branch
BranchTrueFalseTotal
defined $jac ? : 0 0 0
702
703 }
704
705 }
706  
707 # if Jacobian matrix is undefined, use identity matrix
708 0 ▶ $jac = Math::Matrix->diagonal((1) x @{$data}) if (! defined($jac));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $jac 0 0 0
709  
710 # if output values wanted
711 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
712
713 # return Jacobian and output values
714 0 return($jac, $data);
715
716 } else {
717
718 # return Jacobian only
719 0 return($jac);
720
721 }
722
723 }
724  
725 # get/set PCS encoding
726 # for use with ICC::Support::PCS objects
727 # parameters: ([PCS_encoding])
728 # returns: (PCS_encoding)
729 sub pcs {
730  
731 # get parameters
732 0 ▶ my ($self, $pcs) = @_;
Subroutine pcs: not called CC=4 SCAR=30.0
Pod undocumented
733  
734 # if PCS parameter is supplied
735 0 ▶ if (defined($pcs)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pcs) { } 0 0 0
736
737 # if a valid PCS encoding
738 0 ▶ if (grep {$pcs == $_} (3, 8)) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$pcs == $_;} 3, 8) { } 0 0 0
739
740 # copy to tag header hash
741 0 $self->[0]{'pcs_encoding'} = $pcs;
742
743 # return PCS encoding
744 0 return($pcs);
745
746 } else {
747
748 # error
749 0 croak('invalid PCS encoding');
750
751 }
752
753 } else {
754
755 # if PCS is defined in tag header
756 0 ▶ if (defined($self->[0]{'pcs_encoding'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[0]{'pcs_encoding'}) { } 0 0 0
757
758 # return PCS encoding
759 0 return($self->[0]{'pcs_encoding'});
760
761 } else {
762
763 # error
764 0 croak('can\'t determine PCS encoding');
765
766 }
767
768 }
769
770 }
771  
772 # get/set white point
773 # parameters: ([white_point])
774 # returns: (white_point)
775 sub wtpt {
776  
777 # get parameters
778 0 ▶ my ($self, $wtpt) = @_;
Subroutine wtpt: not called CC=5 SCAR=34.0
Pod undocumented
779  
780 # if white point parameter is supplied
781 0 ▶ if (defined($wtpt)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $wtpt) { } 0 0 0
782
783 # if an array of three scalars
784 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
785
786 # copy to tag header hash
787 0 $self->[0]{'wtpt'} = $wtpt;
788
789 # return white point
790 0 return($wtpt);
791
792 } else {
793
794 # error
795 0 croak('invalid white point');
796
797 }
798
799 } else {
800
801 # if white point is defined in tag header
802 0 ▶ if (defined($self->[0]{'wtpt'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[0]{'wtpt'}) { } 0 0 0
803
804 # return return white point
805 0 return($self->[0]{'wtpt'});
806
807 } else {
808
809 # error
810 0 croak('can\'t determine white point');
811
812 }
813
814 }
815
816 }
817  
818 # print object contents to string
819 # format is an array structure
820 # parameter: ([format])
821 # returns: (string)
822 sub sdump {
823  
824 # get parameters
825 0 ▶ my ($self, $p) = @_;
Subroutine sdump: not called CC=11 SCAR=48.8
Pod documented
826  
827 # local variables
828 0 my ($element, $fmt, $s, $pt, $st);
829  
830 # resolve parameter to an array reference
831 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
832  
833 # get format string
834 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
835  
836 # set string to object ID
837 0 $s = sprintf("'%s' object, (0x%x)\n", ref($self), $self);
838  
839 # if format contains 'o'
840 0 ▶ if ($fmt =~ m/s/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt =~ /s/) 0 0 0
841
842 # get default parameter
843 0 $pt = $p->[-1];
844
845 # for each processing element
846 0 for my $i (0 .. $#{$self->[1]}) {
847
848 # get element reference
849 0 $element = $self->[1][$i];
850
851 # if processing element is undefined
852 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
853
854 # append message
855 0 $s .= "\tprocessing element is undefined\n";
856
857 # if processing element is not a blessed object
858 } elsif (! Scalar::Util::blessed($element)) {
859
860 # append message
861 0 $s .= "\tprocessing element is not a blessed object\n";
862
863 # if processing element has an 'sdump' method
864 } elsif ($element->can('sdump')) {
865
866 # get 'sdump' string
867 0 ▶ $st = $element->sdump(defined($p->[$i + 1]) ? $p->[$i + 1] : $pt);
Branch: 1 branch
BranchTrueFalseTotal
defined $$p[$i + 1] ? : 0 0 0
868
869 # prepend tabs to each line
870 0 $st =~ s/^/\t/mg;
871
872 # append 'sdump' string
873 0 $s .= $st;
874
875 # processing element is object without an 'sdump' method
876 } else {
877
878 # append object info
879 0 $s .= sprintf("\t'%s' object, (0x%x)\n", ref($element), $element);
880
881 }
882
883 }
884
885 }
886  
887 # return
888 0 return($s);
889  
890 }
891  
892 # transform list
893 # parameters: (object_reference, list, [hash])
894 # returns: (list)
895 sub _trans0 {
896  
897 # local variables
898 0 ▶ my ($self, $hash, $data);
Subroutine _trans0: not called CC=2 SCAR=17.9
899  
900 # get object reference
901 0 $self = shift();
902  
903 # get optional hash
904 0 ▶ $hash = pop() if (ref($_[-1]) eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] eq "HASH" 0 0 0
905  
906 # process data
907 0 $data = _trans1($self, [@_], $hash);
908  
909 # return list
910 0 return(@{$data});
911  
912 }
913  
914 # transform vector
915 # parameters: (object_reference, vector, [hash])
916 # returns: (vector)
917 sub _trans1 {
918  
919 # get parameters
920 0 ▶ my ($self, $data, $hash) = @_;
Subroutine _trans1: not called CC=5 SCAR=34.0
921  
922 # for each processing element (note: sequence is from the last element to the first)
923 0 for my $i (reverse(0 .. $#{$self->[1]})) {
924
925 # if processing element defined, and transform mask bit set
926 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
927
928 # transform data
929 0 $data = $self->[1][$i]->_trans1($data, $hash);
930
931 # clip output values if clipping mask bit set
932 0 ▶ ICC::Shared::clip_struct($data) if ($self->[3] & 0x01 << $i);
Branch: 1 branch
BranchTrueFalseTotal
if $self->[3] & 1 << $i 0 0 0
933
934 }
935
936 }
937
938 # return
939 0 return($data);
940
941 }
942  
943 # transform matrix (2-D array -or- Math::Matrix object)
944 # parameters: (object_reference, matrix, [hash])
945 # returns: (matrix)
946 sub _trans2 {
947  
948 # get parameters
949 0 ▶ my ($self, $data, $hash) = @_;
Subroutine _trans2: not called CC=5 SCAR=34.0
950  
951 # for each processing element (note: sequence is from the last element to the first)
952 0 for my $i (reverse(0 .. $#{$self->[1]})) {
953
954 # if processing element defined, and transform mask bit set
955 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
956
957 # transform data
958 0 $data = $self->[1][$i]->_trans2($data, $hash);
959
960 # clip output values if clipping mask bit set
961 0 ▶ ICC::Shared::clip_struct($data) if ($self->[3] & 0x01 << $i);
Branch: 1 branch
BranchTrueFalseTotal
if $self->[3] & 1 << $i 0 0 0
962
963 }
964
965 }
966  
967 # return
968 0 return($data);
969  
970 }
971  
972 # transform structure
973 # parameters: (object_reference, structure, [hash])
974 # returns: (structure)
975 sub _trans3 {
976  
977 # get parameters
978 0 ▶ my ($self, $in, $hash) = @_;
Subroutine _trans3: not called CC=1 SCAR=6.9
979  
980 # transform the array structure
981 0 _crawl($self, $in, my $out = [], $hash);
982  
983 # return
984 0 return($out);
985  
986 }
987  
988 # recursive transform
989 # array structure is traversed until scalar arrays are found and transformed
990 # parameters: (ref_to_object, input_array_reference, output_array_reference, hash)
991 sub _crawl {
992  
993 # get parameters
994 0 ▶ my ($self, $in, $out, $hash) = @_;
Subroutine _crawl: not called CC=4 SCAR=30.0
995  
996 # if input is a vector (reference to a scalar array)
997 0 ▶ if (@{$in} == grep {! ref()} @{$in}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$in;} == grep({not ref $_;} @{$in;})) { } 0 0 0
998
999 # transform input vector and copy to output
1000 0 @{$out} = @{_trans1($self, $in, $hash)};
1001
1002 } else {
1003
1004 # for each input element
1005 0 for my $i (0 .. $#{$in}) {
1006
1007 # if an array reference
1008 0 ▶ if (ref($in->[$i]) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $in->[$i] eq 'ARRAY') { } 0 0 0
1009
1010 # transform next level
1011 0 _crawl($self, $in->[$i], $out->[$i] = [], $hash);
1012
1013 } else {
1014
1015 # error
1016 0 croak('invalid transform input');
1017
1018 }
1019
1020 }
1021
1022 }
1023
1024 }
1025  
1026 # check object structure
1027 # parameter: (ref_to_object)
1028 # returns: (number_input_channels, number_output_channels)
1029 sub _check {
1030  
1031 # get object reference
1032 1 ▶ my $self = shift();
Subroutine _check: called CC=22 SCAR=37.2
1033  
1034 # local variables
1035 1 my (@class, $ci, $co);
1036  
1037 # make object class array
1038 1 @class = qw(ICC::Profile::cvst ICC::Profile::matf ICC::Profile::cvst ICC::Profile::clut ICC::Profile::cvst);
1039  
1040 # verify number of processing elements
1041 1 ▶ ($#{$self->[1]} <= 4) || croak('\'mAB_\' object has too many processing elements');
Branch: 1 branch
BranchTrueFalseTotal
$#{$$self[1];} <= 4 or croak("'mAB_' object has too many processing elements") 0 1 1
1042  
1043 # for each processing element (note: sequence is from the last element to the first)
1044 1 for my $i (reverse(0 .. $#{$self->[1]})) {
1045
1046 # if element is defined (matrix and M-curves to may be undefined)
1047 5 ▶ if (defined($self->[1][$i])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][$i]) 5 0 5
1048
1049 # verify element has correct class
1050 5 ▶ (ref($self->[1][$i]) eq $class[$i]) || croak("'mAB_' processing element $i has wrong class");
Branch: 1 branch
BranchTrueFalseTotal
ref $self->[1][$i] eq $class[$i] or croak("'mAB_' processing element $i has wrong class") 0 5 5
1051
1052 # if element has 'cin' method
1053 5 ▶ if ($self->[1][$i]->can('cin')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[1][$i]->can("cin")) 5 0 5
1054
1055 # if number of input channels is undefined
1056 5 ▶ if (! defined($ci)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ci) 1 4 5
1057
1058 # set number of input channels
1059 1 $ci = $self->[1][$i]->cin();
1060
1061 }
1062
1063 # if number of output channels is defined
1064 5 ▶ if (defined($co)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $co) 4 1 5
1065
1066 # verify input channels of this element match output channels of previous element
1067 4 ▶ ($self->[1][$i]->cin() == $co) || croak("'mAB_' processing element $i has wrong number of channels");
Branch: 1 branch
BranchTrueFalseTotal
$self->[1][$i]->cin == $co or croak("'mAB_' processing element $i has wrong number of channels") 0 4 4
1068
1069 }
1070
1071 }
1072
1073 # if element has 'cout' method
1074 5 ▶ if ($self->[1][$i]->can('cout')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->[1][$i]->can("cout")) 5 0 5
1075
1076 # set number of output channels
1077 5 $co = $self->[1][$i]->cout();
1078
1079 }
1080
1081 }
1082
1083 }
1084  
1085 # verify B-curves are defined
1086 1 ▶ (defined($self->[1][0])) || croak('B-curves are required');
Branch: 1 branch
BranchTrueFalseTotal
defined $self->[1][0] or croak("B-curves are required") 0 1 1
1087  
1088 # verify matrix and M-curves are both defined, or neither
1089 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
1090  
1091 # verify CLUT and A-curves are both defined, or neither
1092 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
1093  
1094 # if matrix defined
1095 1 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) 1 0 1
1096
1097 # verify object has 3 output channels
1098 1 ▶ ($co == 3) || croak("matrix processing element not permitted with $co output channels");
Branch: 1 branch
BranchTrueFalseTotal
$co == 3 or croak("matrix processing element not permitted with $co output channels") 0 1 1
1099
1100 # verify matrix size (3x3)
1101 1 ▶ ($self->[1][1]->cin() == 3 && $self->[1][1]->cout() == 3) || 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
1102
1103 # verify offset size (undefined, 0 or 3)
1104 1 ▶ (! defined($self->[1][1][2]) || @{$self->[1][1][2]} == 0 || @{$self->[1][1][2]} == 3) || 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
1105
1106 }
1107  
1108 # return
1109 1 return($ci, $co);
1110  
1111 }
1112  
1113 # set M-curves, matrix, and B-curves
1114 # equivalent to a matrix-based display profile
1115 # parameters: (ref_to_object, ref_to_profile_object)
1116 sub _newICCmatrix {
1117  
1118 # get parameters
1119 0 ▶ my ($self, $disp) = @_;
Subroutine _newICCmatrix: not called CC=9 SCAR=45.0
1120  
1121 # local variables
1122 0 my (@XYZ, @TRC, $wtpt, $bkpt, $id, $mat);
1123  
1124 # verify an RGB/XYZ display profile
1125 0 ▶ (UNIVERSAL::isa($disp, 'ICC::Profile') && $disp->profile_header->[3] eq 'mntr' && $disp->profile_header->[4] eq 'RGB ' && $disp->profile_header->[5] eq 'XYZ ') || 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
1126  
1127 # get primary tags
1128 0 @XYZ = $disp->tag(qw(rXYZ gXYZ bXYZ));
1129  
1130 # get TRC tags
1131 0 @TRC = $disp->tag(qw(rTRC gTRC bTRC));
1132  
1133 # verify a matrix profile
1134 0 ▶ (@XYZ == 3 && @TRC == 3) || 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
1135  
1136 # set input colorspace
1137 0 $self->[0]{'input_cs'} = 'RGB ';
1138  
1139 # set output colorspace
1140 0 $self->[0]{'output_cs'} = 'XYZ ';
1141  
1142 # set PCS encoding
1143 0 $self->[0]{'pcs_encoding'} = 7;
1144  
1145 # get white point tag
1146 0 $wtpt = $disp->tag('wtpt');
1147  
1148 # set white point value
1149 0 ▶ $self->[0]{'wtpt'} = [@{$wtpt->XYZ}] if (defined($wtpt));
Branch: 1 branch
BranchTrueFalseTotal
if defined $wtpt 0 0 0
1150  
1151 # get black point tag
1152 0 $bkpt = $disp->tag('bkpt');
1153  
1154 # set black point value
1155 0 ▶ $self->[0]{'bkpt'} = [@{$bkpt->XYZ}] if (defined($bkpt));
Branch: 1 branch
BranchTrueFalseTotal
if defined $bkpt 0 0 0
1156  
1157 # make identity curve
1158 0 $id = ICC::Profile::curv->new();
1159  
1160 # make Math::Matrix object from primary tags
1161 0 $mat = Math::Matrix->new(map {$_->XYZ()} @XYZ)->transpose->multiply_scalar(32768/65535);
1162  
1163 # set B-curves
1164 0 $self->[1][0] = ICC::Profile::cvst->new([$id, $id, $id]);
1165  
1166 # set matrix
1167 0 $self->[1][1] = ICC::Profile::matf->new({'matrix' => $mat});
1168  
1169 # set M-curves
1170 0 $self->[1][2] = ICC::Profile::cvst->new(Storable::dclone(\@TRC));
1171  
1172 # set transform mask
1173 0 $self->[2] = 0x07;
1174  
1175 }
1176  
1177 # make new mAB_ tag from attribute hash
1178 # hash may contain pointers to B-curves, matrix, M-curves, CLUT, or A-curves
1179 # keys are: ('b_curves', 'matrix', 'm_curves', 'clut', 'a_curves')
1180 # tag elements not specified in the hash are left empty
1181 # parameters: (ref_to_object, ref_to_attribute_hash)
1182 sub _new_from_hash {
1183  
1184 # get parameters
1185 0 ▶ my ($self, $hash) = @_;
Subroutine _new_from_hash: not called CC=4 SCAR=30.0
1186  
1187 # set attribute list (key => [reference_type, array_index])
1188 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]);
1189  
1190 # for each attribute
1191 0 for my $attr (keys(%{$hash})) {
1192
1193 # if value defined
1194 0 ▶ if (defined($hash->{$attr})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $hash->{$attr}) 0 0 0
1195
1196 # if correct reference type
1197 0 ▶ if (ref($hash->{$attr}) eq $list{$attr}[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash->{$attr} eq $list{$attr}[0]) { } 0 0 0
1198
1199 # set tag element
1200 0 $self->[1][$list{$attr}[1]] = $hash->{$attr};
1201
1202 # set transform mask bit
1203 0 $self->[2] |= (0x01 << $list{$attr}[1]);
1204
1205 } else {
1206
1207 # error
1208 0 croak("wrong object type for $attr key");
1209
1210 }
1211
1212 }
1213
1214 }
1215
1216 }
1217  
1218 # read mAB_ tag from ICC profile
1219 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
1220 sub _readICCmAB_ {
1221  
1222 # get parameters
1223 1 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _readICCmAB_: called CC=20 SCAR=31.9
1224  
1225 # local variables
1226 1 my ($buf, @mft, $pel, $mark, @mat, $bytes, $gsa);
1227  
1228 # set tag signature
1229 1 $self->[0]{'signature'} = $tag->[0];
1230  
1231 # set input colorspace
1232 1 $self->[0]{'input_cs'} = $parent->[1][4];
1233  
1234 # set output colorspace
1235 1 $self->[0]{'output_cs'} = $parent->[1][5];
1236  
1237 # seek start of tag
1238 1 seek($fh, $tag->[1], 0);
1239  
1240 # read tag header
1241 1 read($fh, $buf, 32);
1242  
1243 # unpack header
1244 1 @mft = unpack('a4 x4 C2 x2 N5', $buf);
1245
1246 # verify tag signature
1247 1 ▶ ($mft[0] eq 'mAB ') or croak('wrong tag type');
Branch: 1 branch
BranchTrueFalseTotal
$mft[0] eq "mAB " or croak("wrong tag type") 0 1 1
1248  
1249 # verify number input channels (1 to 15)
1250 1 ▶ ($mft[1] > 0 && $mft[1] < 16) || 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
1251  
1252 # verify number output channels (1 to 15)
1253 1 ▶ ($mft[2] > 0 && $mft[2] < 16) || 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
1254  
1255 # if B-curves are defined
1256 1 ▶ if ($mft[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[3]) 1 0 1
1257
1258 # make 'cvst' object for B-curves
1259 1 $pel = ICC::Profile::cvst->new();
1260
1261 # set file pointer to start of first B-curve
1262 1 $mark = $tag->[1] + $mft[3];
1263
1264 # for each output channel
1265 1 for my $i (0 .. $mft[2] - 1) {
1266
1267 # adjust file pointer to 4-byte boundary
1268 3 $mark += (-$mark % 4);
1269
1270 # seek to start of curve
1271 3 seek($fh, $mark, 0);
1272
1273 # read curve type
1274 3 read($fh, $buf, 4);
1275
1276 # if 'curv' type
1277 3 ▶ if ($buf eq 'curv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($buf eq 'curv') { } 0 3 3
elsif ($buf eq 'para') { } 3 0 3
1278
1279 # parse 'curv' object
1280 0 $pel->[1][$i] = ICC::Profile::curv->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1281
1282 } elsif ($buf eq 'para') {
1283
1284 # parse 'para' object
1285 3 $pel->[1][$i] = ICC::Profile::para->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1286
1287 } else {
1288
1289 # error
1290 0 croak('unsupported curve type or invalid tag structure');
1291
1292 }
1293
1294 # mark current file pointer location
1295 3 $mark = tell($fh);
1296
1297 }
1298
1299 # set signature
1300 1 $pel->[0]{'signature'} = 'mAB_';
1301
1302 # add processing element
1303 1 $self->[1][0] = $pel;
1304
1305 # set transform mask
1306 1 $self->[2] |= 0x01;
1307
1308 }
1309  
1310 # if matrix is defined
1311 1 ▶ if ($mft[4]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[4]) 1 0 1
1312
1313 # make 'matf' object for matrix
1314 1 $pel = ICC::Profile::matf->new();
1315
1316 # seek to start of matrix
1317 1 seek($fh, $tag->[1] + $mft[4], 0);
1318
1319 # read matrix
1320 1 $pel->_read_matf($fh, 3, 3, 1, 2);
1321
1322 # set signature
1323 1 $pel->[0]{'signature'} = 'mAB_';
1324
1325 # add processing element
1326 1 $self->[1][1] = $pel;
1327
1328 # set transform mask
1329 1 $self->[2] |= 0x02;
1330
1331 }
1332  
1333 # if M-curves are defined
1334 1 ▶ if ($mft[5]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[5]) 1 0 1
1335
1336 # make 'cvst' object for M-curves
1337 1 $pel = ICC::Profile::cvst->new();
1338
1339 # set file pointer to start of first M-curve
1340 1 $mark = $tag->[1] + $mft[5];
1341
1342 # for each output channel
1343 1 for my $i (0 .. $mft[2] - 1) {
1344
1345 # adjust file pointer to 4-byte boundary
1346 3 $mark += (-$mark % 4);
1347
1348 # seek to start of curve
1349 3 seek($fh, $mark, 0);
1350
1351 # read curve type
1352 3 read($fh, $buf, 4);
1353
1354 # if 'curv' type
1355 3 ▶ if ($buf eq 'curv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($buf eq 'curv') { } 0 3 3
elsif ($buf eq 'para') { } 3 0 3
1356
1357 # parse 'curv' object
1358 0 $pel->[1][$i] = ICC::Profile::curv->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1359
1360 } elsif ($buf eq 'para') {
1361
1362 # parse 'para' object
1363 3 $pel->[1][$i] = ICC::Profile::para->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1364
1365 } else {
1366
1367 # error
1368 0 croak('unsupported curve type or invalid tag structure');
1369
1370 }
1371
1372 # mark current file pointer location
1373 3 $mark = tell($fh);
1374
1375 }
1376
1377 # set signature
1378 1 $pel->[0]{'signature'} = 'mAB_';
1379
1380 # add processing element
1381 1 $self->[1][2] = $pel;
1382
1383 # set transform mask
1384 1 $self->[2] |= 0x04;
1385
1386 }
1387  
1388 # if CLUT defined
1389 1 ▶ if ($mft[6]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[6]) 1 0 1
1390
1391 # make 'clut' object for CLUT
1392 1 $pel = ICC::Profile::clut->new();
1393
1394 # seek to start of CLUT
1395 1 seek($fh, $tag->[1] + $mft[6], 0);
1396
1397 # read header
1398 1 read($fh, $buf, 20);
1399
1400 # unpack header
1401 1 @mat = unpack('C17', $buf);
1402
1403 # get CLUT byte width
1404 1 $bytes = pop(@mat);
1405
1406 # save CLUT byte width
1407 1 $pel->[0]{'clut_bytes'} = $bytes;
1408
1409 # set number of input channels
1410 1 $pel->[0]{'input_channels'} = $mft[1];
1411  
1412 # set number of output channels
1413 1 $pel->[0]{'output_channels'} = $mft[2];
1414  
1415 # make grid size array
1416 1 $gsa = [grep {$_} @mat];
1417
1418 # read 'clut' data
1419 1 $pel->_read_clut($fh, $mft[2], $gsa, $bytes);
1420
1421 # save grid size array
1422 1 $pel->[2] = [@{$gsa}];
1423
1424 # set signature
1425 1 $pel->[0]{'signature'} = 'mAB_';
1426
1427 # add processing element
1428 1 $self->[1][3] = $pel;
1429
1430 # set transform mask
1431 1 $self->[2] |= 0x08;
1432
1433 }
1434  
1435 # if A-curves are defined
1436 1 ▶ if ($mft[7]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mft[7]) 1 0 1
1437
1438 # make 'cvst' object for A-curves
1439 1 $pel = ICC::Profile::cvst->new();
1440
1441 # set file pointer to start of first A-curve
1442 1 $mark = $tag->[1] + $mft[7];
1443
1444 # for each input channel
1445 1 for my $i (0 .. $mft[1] - 1) {
1446
1447 # adjust file pointer to 4-byte boundary
1448 3 $mark += (-$mark % 4);
1449
1450 # seek to start of curve
1451 3 seek($fh, $mark, 0);
1452
1453 # read curve type
1454 3 read($fh, $buf, 4);
1455
1456 # if 'curv' type
1457 3 ▶ if ($buf eq 'curv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($buf eq 'curv') { } 3 0 3
elsif ($buf eq 'para') { } 0 0 0
1458
1459 # parse 'curv' object
1460 3 $pel->[1][$i] = ICC::Profile::curv->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1461
1462 } elsif ($buf eq 'para') {
1463
1464 # parse 'para' object
1465 0 $pel->[1][$i] = ICC::Profile::para->new_fh($self, $fh, ['cvst', $mark, 0, 0]);
1466
1467 } else {
1468
1469 # error
1470 0 croak('unsupported curve type or invalid tag structure');
1471
1472 }
1473
1474 # mark current file pointer location
1475 3 $mark = tell($fh);
1476
1477 }
1478
1479 # set signature
1480 1 $pel->[0]{'signature'} = 'mAB_';
1481
1482 # add processing element
1483 1 $self->[1][4] = $pel;
1484
1485 # set transform mask
1486 1 $self->[2] |= 0x10;
1487
1488 }
1489  
1490 }
1491  
1492 # write mAB_ tag to ICC profile
1493 # parameters: (ref_to_object, ref_to_parent_object, file_handle, ref_to_tag_table_entry)
1494 sub _writeICCmAB_ {
1495  
1496 # get parameters
1497 1 ▶ my ($self, $parent, $fh, $tag) = @_;
Subroutine _writeICCmAB_: called CC=20 SCAR=31.3
1498  
1499 # local variables
1500 1 my (@mft, $offset, @mat, $bytes, $size);
1501  
1502 # set tag type
1503 1 $mft[0] = 'mAB ';
1504  
1505 # check object structure
1506 1 @mft[1, 2] = _check($self);
1507  
1508 # initialize offset
1509 1 $offset = 32;
1510  
1511 # set offset to B-curves
1512 1 $mft[3] = 32;
1513  
1514 # if B-curves defined
1515 1 ▶ if (defined($self->[1][0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][0]) { } 1 0 1
1516
1517 # for each B-curve
1518 1 for my $curve (@{$self->[1][0]->array()}) {
1519
1520 # add curve size
1521 3 $offset += $curve->size;
1522
1523 # pad to 4-bytes
1524 3 $offset += (-$offset % 4);
1525
1526 }
1527
1528 } else {
1529
1530 # error
1531 0 croak('B-curves are required');
1532
1533 }
1534  
1535 # if matrix is defined
1536 1 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) { } 1 0 1
1537
1538 # verify output channels
1539 1 ▶ ($mft[2] == 3) || 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
1540
1541 # set offset
1542 1 $mft[4] = $offset;
1543
1544 # increment offset for matrix size
1545 1 $offset += 48;
1546
1547 } else {
1548
1549 # set offset
1550 0 $mft[4] = 0;
1551
1552 }
1553  
1554 # if M-curves defined
1555 1 ▶ if (defined($self->[1][2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][2]) { } 1 0 1
1556
1557 # verify output channels
1558 1 ▶ ($mft[2] == 3) || 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
1559
1560 # set offset
1561 1 $mft[5] = $offset;
1562
1563 # for each M-curve
1564 1 for my $curve (@{$self->[1][2]->array()}) {
1565
1566 # add curve size
1567 3 $offset += $curve->size;
1568
1569 # pad to 4-bytes
1570 3 $offset += (-$offset % 4);
1571
1572 }
1573
1574 } else {
1575
1576 # set offset
1577 0 $mft[5] = 0;
1578
1579 }
1580  
1581 # if CLUT defined
1582 1 ▶ if (defined($self->[1][3])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][3]) { } 1 0 1
1583
1584 # set offset
1585 1 $mft[6] = $offset;
1586
1587 # get CLUT data size
1588 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
1589
1590 # add CLUT size to offset
1591 1 $offset += 20 + $self->[1][3]->_clut_size($bytes);
1592
1593 # pad to 4-byte boundary
1594 1 $offset += (-$offset % 4);
1595
1596 } else {
1597
1598 # set offset
1599 0 $mft[6] = 0;
1600
1601 }
1602  
1603 # if A-curves defined
1604 1 ▶ if (defined($self->[1][4])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][4]) { } 1 0 1
1605
1606 # set offset
1607 1 $mft[7] = $offset;
1608
1609 } else {
1610
1611 # set offset
1612 0 $mft[7] = 0;
1613
1614 }
1615  
1616 # seek start of tag
1617 1 seek($fh, $tag->[1], 0);
1618  
1619 # write header
1620 1 print $fh pack('a4 x4 C2 x2 N5', @mft);
1621  
1622 # seek start of B-curves
1623 1 seek($fh, $tag->[1] + $mft[3], 0);
1624  
1625 # for each B-curve
1626 1 for my $curve (@{$self->[1][0]->array()}) {
1627
1628 # write curve object
1629 3 $curve->write_fh($self->[1][0], $fh, ['cvst', tell($fh), 0, 0]);
1630
1631 # add padding to 4-byte boundary
1632 3 seek($fh, (-tell($fh) % 4), 1);
1633
1634 }
1635  
1636 # if matrix is defined
1637 1 ▶ if (defined($self->[1][1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][1]) 1 0 1
1638
1639 # seek start of matrix
1640 1 seek($fh, $tag->[1] + $mft[4], 0);
1641
1642 # write matrix
1643 1 $self->[1][1]->_write_matf($fh, 1, 2);
1644
1645 }
1646  
1647 # if M-curves are defined
1648 1 ▶ if (defined($self->[1][2])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][2]) 1 0 1
1649
1650 # seek start of M-curves
1651 1 seek($fh, $tag->[1] + $mft[5], 0);
1652
1653 # for each M-curve
1654 1 for my $curve (@{$self->[1][2]->array()}) {
1655
1656 # write curve object
1657 3 $curve->write_fh($self->[1][2], $fh, ['cvst', tell($fh), 0, 0]);
1658
1659 # add padding to 4-byte boundary
1660 3 seek($fh, (-tell($fh) % 4), 1);
1661
1662 }
1663
1664 }
1665  
1666 # if CLUT is defined
1667 1 ▶ if (defined($self->[1][3])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][3]) 1 0 1
1668
1669 # for each possible input channel
1670 1 for my $i (0 .. 15) {
1671
1672 # set grid size
1673 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
1674
1675 }
1676
1677 # set CLUT byte width
1678 1 $mat[16] = $bytes;
1679
1680 # seek start of CLUT
1681 1 seek($fh, $tag->[1] + $mft[6], 0);
1682
1683 # write CLUT header
1684 1 print $fh pack('C17 x3', @mat);
1685
1686 # write CLUT
1687 1 $self->[1][3]->_write_clut($fh, $self->[1][3]->gsa(), $bytes);
1688
1689 }
1690  
1691 # if A-curves are defined
1692 1 ▶ if (defined($self->[1][4])) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->[1][4]) 1 0 1
1693
1694 # seek start of A-curves
1695 1 seek($fh, $tag->[1] + $mft[7], 0);
1696
1697 # for each M-curve
1698 1 for my $curve (@{$self->[1][4]->array()}) {
1699
1700 # write curve object
1701 3 $curve->write_fh($self->[1][4], $fh, ['cvst', tell($fh), 0, 0]);
1702
1703 # add padding to 4-byte boundary
1704 3 seek($fh, (-tell($fh) % 4), 1);
1705
1706 }
1707
1708 }
1709
1710 }
1711  
1712 2 1;
« lib/ICC/Support/geo1.pm ↑ Summary lib/ICC/Profile/mBA_.pm »