Image/ExifTool/Trailer.pm

filter: Statementstmt 46.1% 60 / 130 Branchbran 25.5% 24 / 94 Conditioncond 12.5% 9 / 72 MC/DCmcdc 0.0% 0 / 41 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 3 totaltotal 28.3% 98 / 346 CC 74 SCAR 60.3
CC
74
Cov
31%
ProcessOnePlus
600.0
ProcessGoogle
510.2
ProcessVivo
27.2
CRAP 414.2
« Image/ExifTool/MacOS.pm ↑ Summary Image/ExifTool/OpenEXR.pm »
1 #------------------------------------------------------------------------------
2 # File: Trailer.pm
3 #
4 # Description: Read JPEG trailer written by various makes of phone
5 #
6 # Revisions: 2025-01-27 - P. Harvey Created
7 #------------------------------------------------------------------------------
8  
9 package Image::ExifTool::Trailer;
10  
11 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Image::ExifTool qw(:DataAccess :Utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 $VERSION = '1.01';
16  
17 5 %Image::ExifTool::Trailer::Vivo = (
18 GROUPS => { 0 => 'Trailer', 1 => 'Vivo', 2 => 'Image' },
19 VARS => { ID_FMT => 'none' },
20 NOTES => 'Information written in JPEG trailer by some Vivo phones.',
21 # (don't know for sure what type of image this is, but it is in JPEG format)
22 HDRImage => {
23 Notes => 'highlights of HDR image',
24 Groups => { 2 => 'Preview' },
25 Binary => 1,
26 },
27 JSONInfo => { },
28 HiddenData => {
29 Notes => 'hidden in EXIF, not in trailer. This data is lost if the file is edited',
30 Groups => { 0 => 'EXIF' },
31 },
32 );
33  
34 5 %Image::ExifTool::Trailer::OnePlus = (
35 GROUPS => { 0 => 'Trailer', 1 => 'OnePlus', 2 => 'Image' },
36 NOTES => 'Information written in JPEG trailer by some OnePlus phones.',
37 JSONInfo => { },
38 'private.emptyspace' => { # length of the entire OnePlus trailer
39 Name => 'OnePlusTrailerLen',
40 ValueConv => 'length $val == 4 ? unpack("N", $val) : $val',
41 Unknown => 1,
42 },
43 'watermark.device' => {
44 Name => 'Device',
45 ValueConv => '"0x" . join(" ", unpack("H10Z*", $val))',
46 Format => 'string',
47 },
48 );
49  
50 # Google and/or Android information in JPEG trailer
51 5 %Image::ExifTool::Trailer::Google = (
52 GROUPS => { 0 => 'Trailer', 1 => 'Google', 2 => 'Image' },
53 NOTES => q{
54 Google-defined information written in the trailer of JPEG images by some
55 phones. This information is referenced by DirectoryItem entries in the XMP.
56 Note that some of this information may also be referenced from other
57 metadata formats, and hence may be extracted twice. For example,
58 MotionPhotoVideo may also exist within a Samsung trailer as
59 EmbbededVideoFile, or GainMapImage may also exist in an MPF trailer as
60 MPImage2.
61 },
62 MotionPhoto => { Name => 'MotionPhotoVideo', Groups => { 2 => 'Video' } },
63 GainMap => { Name => 'GainMapImage', Groups => { 2 => 'Preview' } },
64 Depth => { Name => 'DepthMapImage', Groups => { 2 => 'Preview' } },
65 Confidence => { Name => 'ConfidenceMapImage',Groups => { 2 => 'Preview' } },
66 'android/depthmap' => { Name => 'DepthMapImage', Groups => { 2 => 'Preview' } },
67 'android/confidencemap' => { Name => 'ConfidenceMapImage', Groups => { 2 => 'Preview' } },
68 );
69  
70 #------------------------------------------------------------------------------
71 # Process Vivo trailer
72 # Inputs: 0) ExifTool object reference, 1) dirInfo reference
73 # Returns: 1 on success, 0 on failure, -1 if we must scan for the start
74 # of the trailer to set the ExifTool TrailerStart member
75 # - takes Offset as positive offset from end of trailer to end of file,
76 # and returns DataPos and DirLen, and updates OutFile when writing
77 sub ProcessVivo($$)
78 45 ▶{
Subroutine ProcessVivo: called CC=17 SCAR=33.0
Pod undocumented
79 45 my ($et, $dirInfo) = @_;
80 45 my $raf = $$dirInfo{RAF};
81 45 my $buff;
82  
83 # return now unless we are at a position to scan for the trailer
84 # (must scan because the trailer footer doesn't indicate the trailer length)
85 45 ▶ return -1 unless $$dirInfo{ScanForTrailer};
Branch: 1 branch
BranchTrueFalseTotal
unless $dirInfo->{"ScanForTrailer"} 19 26 45
86  
87 26 ▶ my $pos = $$et{TrailerStart} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $pos = $et->{"TrailerStart"} or return 0 26 0 26
88 26 my $len = $$et{FileEnd} - $pos - $$dirInfo{Offset};
89 26 ▶ $raf->Seek($pos, 0) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($pos, 0) or return 0 26 0 26
90 26 ▶ return 0 unless $len > 0 and $len < 1e7 and $raf->Read($buff, $len) == $len and
Branch: 1 branch
BranchTrueFalseTotal
unless $len > 0 and $len < 10000000 and $raf->Read($buff, $len) == $len and $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/ and $buff =~ /(streamdata|vivo\{")/g 0 26 26
Condition33%4/12
$len > 0 and $len < 10000000 and $raf->Read($buff, $len) == $len and $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/ and $buff =~ /(streamdata|vivo\{")/g
!ll&&!rl&&r
0026
$len > 0 and $len < 10000000 and $raf->Read($buff, $len) == $len and $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/
!ll&&!rl&&r
0026
$len > 0 and $len < 10000000 and $raf->Read($buff, $len) == $len
!ll&&!rl&&r
0026
$len > 0 and $len < 10000000
!ll&&!rl&&r
0026
MC/DC0%0/5
$len > 0 and $len < 10000000 and $raf->Read($buff, $len) == $len and $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/ and $buff =~ /(streamdata|vivo\{")/g
$len > 0 $len < 10000000 $raf->Read($buff, $len) == $len $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/ $buff =~ /(streamdata|vivo\{")/g
Truth table16%1/6
A and B and C and D and E
A= $len > 0B= $len < 10000000C= $raf->Read($buff, $len) == $lenD= $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/E= $buff =~ /(streamdata|vivo\{")/g
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
91 $buff =~ /\xff{4}\x1b\*9HWfu\x84\x93\xa2\xb1$/ and # validate footer
92 $buff =~ /(streamdata|vivo\{")/g; # find start
93 26 my $start = pos($buff) - length($1);
94 26 ▶ if ($start) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start) 26 0 26
95 26 $pos += $start;
96 26 $len -= $start;
97 26 $buff = substr($buff, $start);
98 }
99 # set trailer position and length
100 26 @$dirInfo{'DataPos','DirLen'} = ($pos, $len);
101  
102 # let ProcessTrailers copy or delete this trailer
103 26 ▶ return -1 if $$dirInfo{OutFile};
Branch: 1 branch
BranchTrueFalseTotal
if $dirInfo->{"OutFile"} 7 19 26
104  
105 19 ▶ $et->DumpTrailer($dirInfo) if $$et{OPTIONS}{Verbose} or $$et{HTML_DUMP};
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"OPTIONS"}{"Verbose"} or $et->{"HTML_DUMP"} 0 19 19
Condition33%1/3
$et->{"OPTIONS"}{"Verbose"} or $et->{"HTML_DUMP"}
l!l&&r!l&&!r
0019
MC/DC0%0/2
$et->{"OPTIONS"}{"Verbose"} or $et->{"HTML_DUMP"}
$et->{"OPTIONS"}{"Verbose"} $et->{"HTML_DUMP"}
Truth table33%1/3
A or B
A= $et->{"OPTIONS"}{"Verbose"}B= $et->{"HTML_DUMP"}
ABresult
1X1
011
000
106 19 my $tbl = GetTagTable('Image::ExifTool::Trailer::Vivo');
107 19 pos($buff) = 0; # rewind search to start of buffer
108 19 ▶ if ($buff =~ /^streamdata\xff\xd8\xff/ and $buff =~ /\xff\xd9stream(info|coun)/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff =~ /^streamdata\xff\xd8\xff/ and $buff =~ /\xff\xd9stream(info|coun)/g) 0 19 19
Condition33%1/3
$buff =~ /^streamdata\xff\xd8\xff/ and $buff =~ /\xff\xd9stream(info|coun)/g
!ll&&!rl&&r
1900
MC/DC0%0/2
$buff =~ /^streamdata\xff\xd8\xff/ and $buff =~ /\xff\xd9stream(info|coun)/g
$buff =~ /^streamdata\xff\xd8\xff/ $buff =~ /\xff\xd9stream(info|coun)/g
Truth table33%1/3
A and B
A= $buff =~ /^streamdata\xff\xd8\xff/B= $buff =~ /\xff\xd9stream(info|coun)/g
ABresult
0X0
100
111
109 0 $et->HandleTag($tbl, HDRImage => substr($buff, 10, pos($buff)-20));
110 }
111 # continue looking for Vivo JSON data
112 19 ▶ if ($buff =~ /vivo\{"/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff =~ /vivo\{"/g) 19 0 19
113 19 my $jsonStart = pos($buff) - 2;
114 19 ▶ if ($buff =~ /\}\0/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff =~ /\}\0/g) 19 0 19
115 19 my $jsonLen = pos($buff) - 1 - $jsonStart;
116 19 $et->HandleTag($tbl, JSONInfo => substr($buff, $jsonStart, $jsonLen));
117 }
118 }
119 19 return 1;
120 }
121  
122 #------------------------------------------------------------------------------
123 # Process OnePlus trailer
124 # Inputs: 0) ExifTool object reference, 1) dirInfo reference
125 # Returns: 1 on success, 0 on failure, -1 if we must scan for the start
126 # of the trailer to set the ExifTool TrailerStart member
127 # - takes Offset as positive offset from end of trailer to end of file,
128 # and returns DataPos and DirLen, and updates OutFile when writing
129 sub ProcessOnePlus($$)
130 0 ▶{
Subroutine ProcessOnePlus: not called CC=24 SCAR=64.0
Pod undocumented
131 0 my ($et, $dirInfo) = @_;
132 0 my $raf = $$dirInfo{RAF};
133 0 my ($buff, $buf2);
134  
135 # return now unless we are at a position to scan for the trailer
136 # (must scan because the trailer footer doesn't indicate the entire trailer length)
137 0 ▶ return -1 unless $$dirInfo{ScanForTrailer};
Branch: 1 branch
BranchTrueFalseTotal
unless $dirInfo->{"ScanForTrailer"} 0 0 0
138  
139 # return -1 to let ProcessTrailers copy or delete the entire trailer
140 0 ▶ return -1 if $$dirInfo{OutFile};
Branch: 1 branch
BranchTrueFalseTotal
if $dirInfo->{"OutFile"} 0 0 0
141  
142 0 ▶ my $start = $$et{TrailerStart} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $start = $et->{"TrailerStart"} or return 0 0 0 0
143 0 ▶ $raf->Seek(-8-$$dirInfo{Offset}, 2) and $raf->Read($buff, 8) == 8 or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek(-8 - $dirInfo->{"Offset"}, 2) and $raf->Read($buff, 8) == 8 or return 0 0 0 0
Condition0%0/3
$raf->Seek(-8 - $dirInfo->{"Offset"}, 2) and $raf->Read($buff, 8) == 8
!ll&&!rl&&r
000
MC/DC0%0/2
$raf->Seek(-8 - $dirInfo->{"Offset"}, 2) and $raf->Read($buff, 8) == 8
$raf->Seek(-8 - $dirInfo->{"Offset"}, 2) $raf->Read($buff, 8) == 8
Truth table0%0/3
A and B
A= $raf->Seek(-8 - $dirInfo->{"Offset"}, 2)B= $raf->Read($buff, 8) == 8
ABresult
0X0
100
111
144 0 my $end = $raf->Tell(); # (same as FileEnd - Offset)
145  
146 0 ▶ my $dump = ($$et{OPTIONS}{Verbose} or $$et{HTML_DUMP});
Condition0%0/3
$et->{'OPTIONS'}{'Verbose'} || $et->{'HTML_DUMP'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$et->{'OPTIONS'}{'Verbose'} || $et->{'HTML_DUMP'}
$et->{'OPTIONS'}{'Verbose'} $et->{'HTML_DUMP'}
Truth table0%0/3
A || B
A= $et->{'OPTIONS'}{'Verbose'}B= $et->{'HTML_DUMP'}
ABresult
1X1
011
000
147 0 my $tagTable = GetTagTable('Image::ExifTool::Trailer::OnePlus');
148 0 my $trailLen = 0;
149 0 ▶ if ($buff =~ /^jxrs...\0$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff =~ /^jxrs...\0$/) 0 0 0
150 0 my $jlen = unpack('x4V', $buff);
151 0 my $maxOff = 0;
152 0 ▶ if ($jlen < $end-$start and $jlen > 8 and $raf->Seek($end-$jlen) and
Branch: 1 branch
BranchTrueFalseTotal
if ($jlen < $end - $start and $jlen > 8 and $raf->Seek($end - $jlen) and $raf->Read($buff, $jlen - 8) == $jlen - 8) 0 0 0
Condition0%0/9
$jlen < $end - $start and $jlen > 8 and $raf->Seek($end - $jlen) and $raf->Read($buff, $jlen - 8) == $jlen - 8
!ll&&!rl&&r
000
$jlen < $end - $start and $jlen > 8 and $raf->Seek($end - $jlen)
!ll&&!rl&&r
000
$jlen < $end - $start and $jlen > 8
!ll&&!rl&&r
000
MC/DC0%0/4
$jlen < $end - $start and $jlen > 8 and $raf->Seek($end - $jlen) and $raf->Read($buff, $jlen - 8) == $jlen - 8
$jlen < $end - $start $jlen > 8 $raf->Seek($end - $jlen) $raf->Read($buff, $jlen - 8) == $jlen - 8
Truth table0%0/5
A and B and C and D
A= $jlen < $end - $startB= $jlen > 8C= $raf->Seek($end - $jlen)D= $raf->Read($buff, $jlen - 8) == $jlen - 8
ABCDresult
0XXX0
10XX0
110X0
11100
11111
153 $raf->Read($buff, $jlen-8) == $jlen-8)
154 {
155 0 $buff =~ s/\0+$//; # remove trailing null(s)
156 0 require Image::ExifTool::Import;
157 0 my $list = Image::ExifTool::Import::ReadJSONObject(undef, \$buff);
158 0 ▶ if (ref $list eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $list eq 'ARRAY') { } 0 0 0
159 0 ▶ $$_{offset} and $$_{offset} > $maxOff and $maxOff = $$_{offset} foreach @$list;
Branch: 1 branch
BranchTrueFalseTotal
$_->{"offset"} and $_->{"offset"} > $maxOff and $maxOff = $_->{"offset"} 0 0 0
Condition0%0/3
$_->{"offset"} and $_->{"offset"} > $maxOff
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{"offset"} and $_->{"offset"} > $maxOff
$_->{"offset"} $_->{"offset"} > $maxOff
Truth table0%0/3
A and B
A= $_->{"offset"}B= $_->{"offset"} > $maxOff
ABresult
0X0
100
111
160 0 $trailLen = $maxOff + $jlen;
161 0 ▶ if ($dump and $trailLen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dump and $trailLen) 0 0 0
Condition0%0/3
$dump and $trailLen
!ll&&!rl&&r
000
MC/DC0%0/2
$dump and $trailLen
$dump $trailLen
Truth table0%0/3
A and B
A= $dumpB= $trailLen
ABresult
0X0
100
111
162 0 $et->DumpTrailer({
163 RAF => $raf,
164 DirName => 'OnePlus',
165 DataPos => $end-$trailLen,
166 DirLen => $trailLen,
167 });
168 }
169 0 $et->HandleTag($tagTable, JSONInfo => $buff);
170 0 foreach (@$list) {
171 0 my ($off, $name, $len) = @$_{qw(offset name length)};
172 0 ▶ next unless $off and $name and $len;
Branch: 1 branch
BranchTrueFalseTotal
unless $off and $name and $len 0 0 0
Condition0%0/6
$off and $name and $len
!ll&&!rl&&r
000
$off and $name
!ll&&!rl&&r
000
MC/DC0%0/3
$off and $name and $len
$off $name $len
Truth table0%0/4
A and B and C
A= $offB= $nameC= $len
ABCresult
0XX0
10X0
1100
1111
173 0 ▶ if ($raf->Seek($end-$jlen-$off) and $raf->Read($buf2, $len) == $len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek($end - $jlen - $off) and $raf->Read($buf2, $len) == $len) 0 0 0
Condition0%0/3
$raf->Seek($end - $jlen - $off) and $raf->Read($buf2, $len) == $len
!ll&&!rl&&r
000
MC/DC0%0/2
$raf->Seek($end - $jlen - $off) and $raf->Read($buf2, $len) == $len
$raf->Seek($end - $jlen - $off) $raf->Read($buf2, $len) == $len
Truth table0%0/3
A and B
A= $raf->Seek($end - $jlen - $off)B= $raf->Read($buf2, $len) == $len
ABresult
0X0
100
111
174 0 $et->HandleTag($tagTable, $name, $buf2, DataPos => $end-$jlen-$off, DataPt => \$buf2);
175 }
176 }
177 } else {
178 0 $et->HandleTag($tagTable, JSONInfo => $buff);
179 0 $et->Warn('Error parsing OnePlus JSON information');
180 }
181 }
182 }
183 0 @$dirInfo{'DataPos','DirLen'} = ($end - $trailLen, $trailLen);
184  
185 0 return 1;
186 }
187  
188 #------------------------------------------------------------------------------
189 # Process Google trailer
190 # Inputs: 0) ExifTool object reference, 1) dirInfo reference
191 # Returns: 1 on success, 0 on failure, -1 if we must scan for the start
192 # of the trailer to set the ExifTool TrailerStart member
193 # - this trailer won't be identified when writing because XMP isn't extracted then
194 sub ProcessGoogle($$)
195 2 ▶{
Subroutine ProcessGoogle: called CC=35 SCAR=62.3
Pod undocumented
196 2 my ($et, $dirInfo) = @_;
197 2 my $raf = $$dirInfo{RAF};
198 2 my $info = $$et{VALUE};
199  
200 2 my ($tag, $mime, $len, $pad) = @$info{qw(DirectoryItemSemantic DirectoryItemMime
201 DirectoryItemLength DirectoryItemPadding)};
202  
203 2 ▶ unless (ref $tag eq 'ARRAY' and ref $mime eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $tag eq "ARRAY" and ref $mime eq "ARRAY") 0 2 2
Condition33%1/3
ref $tag eq "ARRAY" and ref $mime eq "ARRAY"
!ll&&!rl&&r
002
MC/DC0%0/2
ref $tag eq "ARRAY" and ref $mime eq "ARRAY"
ref $tag eq "ARRAY" ref $mime eq "ARRAY"
Truth table33%1/3
A and B
A= ref $tag eq "ARRAY"B= ref $mime eq "ARRAY"
ABresult
0X0
100
111
204 0 undef $pad;
205 0 ($tag, $mime, $len) = @$info{qw(ContainerDirectoryItemDataURI
206 ContainerDirectoryItemMime ContainerDirectoryItemLength)};
207 0 ▶ unless (ref $mime eq 'ARRAY' and ref $tag eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $mime eq "ARRAY" and ref $tag eq "ARRAY") 0 0 0
Condition0%0/3
ref $mime eq "ARRAY" and ref $tag eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
ref $mime eq "ARRAY" and ref $tag eq "ARRAY"
ref $mime eq "ARRAY" ref $tag eq "ARRAY"
Truth table0%0/3
A and B
A= ref $mime eq "ARRAY"B= ref $tag eq "ARRAY"
ABresult
0X0
100
111
208 0 delete $$et{ProcessGoogleTrailer};
209 0 return 0;
210 }
211 }
212 # we need to know TrailerStart to be able to read/write this trailer
213 2 ▶ return -1 unless $$dirInfo{ScanForTrailer};
Branch: 1 branch
BranchTrueFalseTotal
unless $dirInfo->{"ScanForTrailer"} 1 1 2
214  
215 1 delete $$et{ProcessGoogleTrailer}; # reset flag to process the Google trailer
216  
217 1 ▶ return -1 if $$dirInfo{OutFile}; # let caller handle the writing
Branch: 1 branch
BranchTrueFalseTotal
if $dirInfo->{"OutFile"} 0 1 1
218  
219 # sometimes DirectoryItemLength is missing the Primary entry
220 1 ▶ $len = [ $len ] unless ref $len eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $len eq "ARRAY" 1 0 1
221 1 ▶ unshift @$len, 0 while @$len < @$mime;
Branch: 1 branch
BranchTrueFalseTotal
@$len < @$mime and do { unshift @$len, 0 } 1 1 2
222  
223 1 ▶ my $start = $$et{TrailerStart} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $start = $et->{"TrailerStart"} or return 0 1 0 1
224 1 my $end = $$et{FileEnd}; # (ignore Offset for now because some entries may run into other trailers)
225  
226 1 ▶ my $dump = ($$et{OPTIONS}{Verbose} or $$et{HTML_DUMP});
Condition33%1/3
$et->{'OPTIONS'}{'Verbose'} || $et->{'HTML_DUMP'}
l!l&&r!l&&!r
001
MC/DC0%0/2
$et->{'OPTIONS'}{'Verbose'} || $et->{'HTML_DUMP'}
$et->{'OPTIONS'}{'Verbose'} $et->{'HTML_DUMP'}
Truth table33%1/3
A || B
A= $et->{'OPTIONS'}{'Verbose'}B= $et->{'HTML_DUMP'}
ABresult
1X1
011
000
227 1 my $tagTable = GetTagTable('Image::ExifTool::Trailer::Google');
228  
229 # (ignore first entry: "Primary" or "primary_image")
230 1 my ($i, $pos, $buff, $regex, $grp, $type);
231 1 ▶ for ($i=1, $pos=0; defined $$mime[$i]; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $mime->[$i]) 1 0 1
232 1 my $more = $end - $start - $pos;
233 1 ▶ last if $more < 16;
Branch: 1 branch
BranchTrueFalseTotal
if $more < 16 1 0 1
234 0 ▶ next unless $$len[$i] and defined $$tag[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $len->[$i] and defined $tag->[$i] 0 0 0
Condition0%0/3
$len->[$i] and defined $tag->[$i]
!ll&&!rl&&r
000
MC/DC0%0/2
$len->[$i] and defined $tag->[$i]
$len->[$i] defined $tag->[$i]
Truth table0%0/3
A and B
A= $len->[$i]B= defined $tag->[$i]
ABresult
0X0
100
111
235 0 ▶ last if $$len[$i] > $more;
Branch: 1 branch
BranchTrueFalseTotal
if $len->[$i] > $more 0 0 0
236 0 ▶ $raf->Seek($start+$pos) and $raf->Read($buff, 16) == 16 and $raf->Seek($start+$pos) or last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Seek($start + $pos) and $raf->Read($buff, 16) == 16 and $raf->Seek($start + $pos) or last 0 0 0
Condition0%0/6
$raf->Seek($start + $pos) and $raf->Read($buff, 16) == 16 and $raf->Seek($start + $pos)
!ll&&!rl&&r
000
$raf->Seek($start + $pos) and $raf->Read($buff, 16) == 16
!ll&&!rl&&r
000
MC/DC0%0/3
$raf->Seek($start + $pos) and $raf->Read($buff, 16) == 16 and $raf->Seek($start + $pos)
$raf->Seek($start + $pos) $raf->Read($buff, 16) == 16 $raf->Seek($start + $pos)
Truth table0%0/4
A and B and C
A= $raf->Seek($start + $pos)B= $raf->Read($buff, 16) == 16C= $raf->Seek($start + $pos)
ABCresult
0XX0
10X0
1100
1111
237 0 ▶ if ($$mime[$i] eq 'image/jpeg') {
Branch: 2 branches
BranchTrueFalseTotal
if ($mime->[$i] eq 'image/jpeg') { } 0 0 0
elsif ($mime->[$i] eq 'video/mp4') { } 0 0 0
238 0 $regex = '\xff\xd8\xff[\xdb\xe0\xe1]';
239 } elsif ($$mime[$i] eq 'video/mp4') {
240 0 $regex = '\0\0\0.ftyp(mp42|isom)';
241 } else {
242 0 $et->Warn("Google trailer $$tag[$i] $$mime[$i] not handled");
243 0 next;
244 }
245 0 ▶ if ($buff =~ /^$regex/s) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buff =~ /^$regex/s) { } 0 0 0
246 0 ▶ last unless $raf->Read($buff, $$len[$i]) == $$len[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Read($buff, $len->[$i]) == $len->[$i] 0 0 0
247 } else {
248 0 ▶ last if $pos; # don't skip unknown information again
Branch: 1 branch
BranchTrueFalseTotal
if $pos 0 0 0
249 0 ▶ last unless $raf->Read($buff, $more) == $more;
Branch: 1 branch
BranchTrueFalseTotal
unless $raf->Read($buff, $more) == $more 0 0 0
250 0 ▶ last unless $buff =~ /($regex)/sg;
Branch: 1 branch
BranchTrueFalseTotal
unless $buff =~ /($regex)/gs 0 0 0
251 0 $pos += pos($buff) - length($1);
252 0 $more = $end - $start - $pos;
253 0 ▶ last if $$len[$i] > $end - $start - $pos;
Branch: 1 branch
BranchTrueFalseTotal
if $len->[$i] > $end - $start - $pos 0 0 0
254 0 $buff = substr($buff, $pos, $$len[$i]);
255 }
256 0 ▶ unless ($$tagTable{$$tag[$i]}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$tagTable{$tag->[$i]}) 0 0 0
257 0 my $name = $$tag[$i];
258 0 $name =~ s/([^A-Za-z])([a-z])/$1\u$2/g; # capitalize words
259 0 $name = Image::ExifTool::MakeTagName($$tag[$i]);
260 0 ▶ if ($$mime[$i] eq 'image/jpeg') {
Branch: 1 branch
BranchTrueFalseTotal
if ($mime->[$i] eq 'image/jpeg') { } 0 0 0
261 0 ($type, $grp) = ('Image', 'Preview');
262 } else {
263 0 ($type, $grp) = ('Video', 'Video');
264 }
265 0 $et->VPrint(0, $$et{INDENT}, "[adding Google:$name]\n");
266 0 AddTagToTable($tagTable, $$tag[$i], { Name => "$name$type", Groups => { 2 => $grp } });
267 }
268 0 ▶ $dump and $et->DumpTrailer({
Branch: 1 branch
BranchTrueFalseTotal
$dump and $et->DumpTrailer({"RAF", $raf, "DirName", $tag->[$i], "DataPos", $start + $pos, "DirLen", $len->[$i]}) 0 0 0
269 RAF => $raf,
270 DirName => $$tag[$i],
271 DataPos => $start + $pos,
272 DirLen => $$len[$i],
273 });
274 0 $et->HandleTag($tagTable, $$tag[$i], \$buff, DataPos => $start + $pos, DataPt => \$buff);
275 # (haven't seen non-zero padding, but I assume this is how it works
276 0 ▶ $pos += $$len[$i] + (($pad and $$pad[$i]) ? $$pad[$i] : 0);
Branch: 1 branch
BranchTrueFalseTotal
$pad && $pad->[$i] ? : 0 0 0
Condition0%0/3
$pad and $pad->[$i]
!ll&&!rl&&r
000
MC/DC0%0/2
$pad and $pad->[$i]
$pad $pad->[$i]
Truth table0%0/3
A and B
A= $padB= $pad->[$i]
ABresult
0X0
100
111
277 }
278 1 ▶ if (defined $$tag[$i] and defined $$mime[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tag->[$i] and defined $mime->[$i]) 1 0 1
Condition33%1/3
defined $tag->[$i] and defined $mime->[$i]
!ll&&!rl&&r
001
MC/DC0%0/2
defined $tag->[$i] and defined $mime->[$i]
defined $tag->[$i] defined $mime->[$i]
Truth table33%1/3
A and B
A= defined $tag->[$i]B= defined $mime->[$i]
ABresult
0X0
100
111
279 1 $et->Warn("Error reading $$tag[$i] $$mime[$i] from trailer", 1);
280 }
281 1 ▶ return 0 unless $pos;
Branch: 1 branch
BranchTrueFalseTotal
unless $pos 1 0 1
282  
283 0 @$dirInfo{'DataPos','DirLen'} = ($start, $pos);
284  
285 0 return 1;
286 }
287  
288 5 1; # end
289  
290 __END__
« Image/ExifTool/MacOS.pm ↑ Summary Image/ExifTool/OpenEXR.pm »