Image/ExifTool/Real.pm

filter: Statementstmt 86.3% 189 / 219 Branchbran 57.9% 73 / 126 Conditioncond 41.6% 20 / 48 MC/DCmcdc 10.7% 3 / 28 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 67.7% 292 / 431 CC 81 SCAR 43.1
CC
81
Cov
72%
ProcessReal
114.2
ProcessRealMeta
35.7
ProcessRealProperties
16.8
CRAP 74.8
« Image/ExifTool/Kodak.pm ↑ Summary Image/ExifTool/Pentax.pm »
1 #------------------------------------------------------------------------------
2 # File: Real.pm
3 #
4 # Description: Read Real audio/video meta information
5 #
6 # Revisions: 05/16/2006 - P. Harvey Created
7 #
8 # References: 1) http://www.getid3.org/
9 # 2) https://common.helixcommunity.org/nonav/2003/HCS_SDK_r5/htmfiles/rmff.htm
10 #------------------------------------------------------------------------------
11  
12 package Image::ExifTool::Real;
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Image::ExifTool qw(:DataAccess :Utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Image::ExifTool::Canon;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 $VERSION = '1.07';
20  
21 sub ProcessRealMeta($$$);
22 sub ProcessRealProperties($$$);
23  
24 # Real property types (ref PH)
25 1 my %propertyType = (
26 0 => 'int32u',
27 2 => 'string',
28 );
29  
30 # Real Metadata property types
31 1 my %metadataFormat = (
32 1 => 'string', # text
33 2 => 'string', # text list
34 3 => 'flag', # 1 or 4 byte integer
35 4 => 'int32u', # 4-byte integer
36 5 => 'undef', # binary data
37 6 => 'string', # URL
38 7 => 'string', # date
39 8 => 'string', # file name
40 9 => undef, # grouping
41 10 => undef, # reference
42 );
43  
44 # Real Metadata property flag bit descriptions
45 1 my %metadataFlag = (
46 0 => 'Read Only',
47 1 => 'Private',
48 2 => 'Type Descriptor',
49 );
50  
51  
52 # tags used in RealMedia (RM, RV and RMVB) files
53 1 %Image::ExifTool::Real::Media = (
54 GROUPS => { 2 => 'Video' },
55 NOTES => q{
56 These B<Tag ID>'s are Chunk ID's used in RealMedia and RealVideo (RM, RV and
57 RMVB) files.
58 },
59 CONT => { SubDirectory => { TagTable => 'Image::ExifTool::Real::ContentDescr' } },
60 MDPR => { SubDirectory => { TagTable => 'Image::ExifTool::Real::MediaProps' } },
61 PROP => { SubDirectory => { TagTable => 'Image::ExifTool::Real::Properties' } },
62 RJMD => { SubDirectory => { TagTable => 'Image::ExifTool::Real::Metadata' } },
63 );
64  
65 # pseudo-tags used in RealAudio (RA) files
66 1 %Image::ExifTool::Real::Audio = (
67 GROUPS => { 2 => 'Audio' },
68 NOTES => q{
69 Tags in the following table reference information extracted from various
70 versions of RealAudio (RA) files.
71 },
72 '.ra3' => { Name => 'RA3', SubDirectory => { TagTable => 'Image::ExifTool::Real::AudioV3' } },
73 '.ra4' => { Name => 'RA4', SubDirectory => { TagTable => 'Image::ExifTool::Real::AudioV4' } },
74 '.ra5' => { Name => 'RA5', SubDirectory => { TagTable => 'Image::ExifTool::Real::AudioV5' } },
75 );
76  
77 # pseudo-tags used in RealMedia Metafiles and RealMedia Plug-in Metafiles (RAM and RPM)
78 1 %Image::ExifTool::Real::Metafile = (
79 GROUPS => { 2 => 'Video' },
80 NOTES => q{
81 Tags representing information extracted from Real Audio Metafile and
82 RealMedia Plug-in Metafile (RAM and RPM) files.
83 },
84 txt => 'Text',
85 url => 'URL',
86 );
87  
88 1 %Image::ExifTool::Real::Properties = (
89 GROUPS => { 1 => 'Real-PROP', 2 => 'Video' },
90 PROCESS_PROC => \&Image::ExifTool::Canon::ProcessSerialData,
91 VARS => { ID_LABEL => 'Sequence' },
92 FORMAT => 'int32u',
93 0 => { Name => 'MaxBitrate', PrintConv => 'ConvertBitrate($val)' },
94 1 => { Name => 'AvgBitrate', PrintConv => 'ConvertBitrate($val)' },
95 2 => 'MaxPacketSize',
96 3 => 'AvgPacketSize',
97 4 => 'NumPackets',
98 5 => { Name => 'Duration', ValueConv => '$val / 1000', PrintConv => 'ConvertDuration($val)' },
99 6 => { Name => 'Preroll', ValueConv => '$val / 1000', PrintConv => 'ConvertDuration($val)' },
100 7 => { Name => 'IndexOffset', Unknown => 1 },
101 8 => { Name => 'DataOffset', Unknown => 1 },
102 9 => { Name => 'NumStreams', Format => 'int16u' },
103 10 => {
104 Name => 'Flags',
105 Format => 'int16u',
106 PrintConv => { BITMASK => {
107 0 => 'Allow Recording',
108 1 => 'Perfect Play',
109 2 => 'Live',
110 3 => 'Allow Download', #PH (from rmeditor dump)
111 } },
112 },
113 );
114  
115 1 %Image::ExifTool::Real::MediaProps = (
116 GROUPS => { 1 => 'Real-MDPR', 2 => 'Video' },
117 PROCESS_PROC => \&Image::ExifTool::Canon::ProcessSerialData,
118 VARS => { ID_LABEL => 'Sequence' },
119 FORMAT => 'int32u',
120 PRIORITY => 0, # first stream takes priority
121 0 => { Name => 'StreamNumber', Format => 'int16u' },
122 1 => { Name => 'StreamMaxBitrate', PrintConv => 'ConvertBitrate($val)' },
123 2 => { Name => 'StreamAvgBitrate', PrintConv => 'ConvertBitrate($val)' },
124 3 => { Name => 'StreamMaxPacketSize' },
125 4 => { Name => 'StreamAvgPacketSize' },
126 5 => { Name => 'StreamStartTime' },
127 6 => { Name => 'StreamPreroll', ValueConv => '$val / 1000', PrintConv => 'ConvertDuration($val)' },
128 7 => { Name => 'StreamDuration',ValueConv => '$val / 1000', PrintConv => 'ConvertDuration($val)' },
129 8 => { Name => 'StreamNameLen', Format => 'int8u', Unknown => 1 },
130 9 => { Name => 'StreamName', Format => 'string[$val{8}]' },
131 10 => { Name => 'StreamMimeLen', Format => 'int8u', Unknown => 1 },
132 11 => {
133 Name => 'StreamMimeType',
134 Format => 'string[$val{10}]',
135 RawConv => '$self->{RealStreamMime} = $val',
136 },
137 12 => { Name => 'FileInfoLen', Unknown => 1 },
138 13 => {
139 Name => 'FileInfoLen2',
140 # if this condition fails, subsequent tags will not be processed
141 Condition => '$self->{RealStreamMime} eq "logical-fileinfo"',
142 Unknown => 1,
143 },
144 14 => {
145 Name => 'FileInfoVersion',
146 Format => 'int16u',
147 },
148 15 => {
149 Name => 'PhysicalStreams',
150 Format => 'int16u',
151 Unknown => 1,
152 },
153 16 => {
154 Name => 'PhysicalStreamNumbers',
155 Format => 'int16u[$val{15}]',
156 Unknown => 1,
157 },
158 17 => {
159 Name => 'DataOffsets',
160 Format => 'int32u[$val{15}]',
161 Unknown => 1,
162 },
163 18 => {
164 Name => 'NumRules',
165 Format => 'int16u',
166 Unknown => 1,
167 },
168 19 => {
169 Name => 'PhysicalStreamNumberMap',
170 Format => 'int16u[$val{18}]',
171 Unknown => 1,
172 },
173 20 => {
174 Name => 'NumProperties',
175 Format => 'int16u',
176 Unknown => 1,
177 },
178 21 => {
179 Name => 'FileInfoProperties',
180 Format => 'undef[$val{13}-$val{15}*6-$val{18}*2-12]',
181 SubDirectory => { TagTable => 'Image::ExifTool::Real::FileInfo' },
182 },
183 );
184  
185 # Observed FileInfo properties (ref PH)
186 1 %Image::ExifTool::Real::FileInfo = (
187 GROUPS => { 1 => 'Real-MDPR', 2 => 'Video' },
188 PROCESS_PROC => \&ProcessRealProperties,
189 NOTES => q{
190 The following tags have been observed in the FileInfo properties, but any
191 other existing information will also be extracted.
192 },
193 Indexable => { PrintConv => { 0 => 'False', 1 => 'True' } },
194 Keywords => { },
195 Description => { },
196 'File ID' => { Name => 'FileID' },
197 'Content Rating' => {
198 Name => 'ContentRating',
199 PrintConv => {
200 0 => 'No Rating',
201 1 => 'All Ages',
202 2 => 'Older Children',
203 3 => 'Younger Teens',
204 4 => 'Older Teens',
205 5 => 'Adult Supervision Recommended',
206 6 => 'Adults Only',
207 },
208 },
209 Audiences => { },
210 audioMode => { Name => 'AudioMode' },
211 'Creation Date' => {
212 Name => 'CreateDate',
213 Groups => { 2 => 'Time' },
214 ValueConv => q{
215 $val =~ m{(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+)} ?
216 sprintf("%.4d:%.2d:%.2d %.2d:%.2d:%.2d",$3,$2,$1,$4,$5,$6) : $val
217 },
218 PrintConv => '$self->ConvertDateTime($val)',
219 },
220 'Generated By' => { Name => 'Software' },
221 'Modification Date' => {
222 Name => 'ModifyDate',
223 Groups => { 2 => 'Time' },
224 ValueConv => q{
225 $val =~ m{(\d+)/(\d+)/(\d+)\s+(\d+):(\d+):(\d+)} ?
226 sprintf("%.4d:%.2d:%.2d %.2d:%.2d:%.2d",$3,$2,$1,$4,$5,$6) : $val
227 },
228 PrintConv => '$self->ConvertDateTime($val)',
229 },
230 'Target Audiences' => { Name => 'TargetAudiences' },
231 'Audio Format' => { Name => 'AudioFormat' },
232 'Video Quality' => { Name => 'VideoQuality' },
233 videoMode => { Name => 'VideoMode' },
234 );
235  
236 1 %Image::ExifTool::Real::ContentDescr = (
237 GROUPS => { 1 => 'Real-CONT', 2 => 'Video' },
238 PROCESS_PROC => \&Image::ExifTool::Canon::ProcessSerialData,
239 VARS => { ID_LABEL => 'Sequence' },
240 FORMAT => 'int16u',
241 0 => { Name => 'TitleLen', Unknown => 1 },
242 1 => { Name => 'Title', Format => 'string[$val{0}]' },
243 2 => { Name => 'AuthorLen', Unknown => 1 },
244 3 => { Name => 'Author', Format => 'string[$val{2}]', Groups => { 2 => 'Author' } },
245 4 => { Name => 'CopyrightLen', Unknown => 1 },
246 5 => { Name => 'Copyright', Format => 'string[$val{4}]', Groups => { 2 => 'Author' } },
247 6 => { Name => 'CommentLen', Unknown => 1 },
248 7 => { Name => 'Comment', Format => 'string[$val{6}]' },
249 );
250  
251 # Real RJMD meta information (ref PH)
252 1 %Image::ExifTool::Real::Metadata = (
253 GROUPS => { 1 => 'Real-RJMD', 2 => 'Video' },
254 PROCESS_PROC => \&ProcessRealMeta,
255 NOTES => q{
256 The tags below represent information which has been observed in the Real
257 Metadata format, but ExifTool will extract any information it finds in this
258 format. (As far as I can tell from the referenced documentation, string
259 values should be plain text, but this is not the case for the only sample
260 file I have been able to obtain containing this information. These tags
261 could also be split into separate sub-directories, but this will wait until
262 I have better documentation or a more complete set of samples.)
263 },
264 'Album/Name' => 'AlbumName',
265 'Track/Category' => 'TrackCategory',
266 'Track/Comments' => 'TrackComments',
267 'Track/Lyrics' => 'TrackLyrics',
268 );
269  
270 1 %Image::ExifTool::Real::AudioV3 = (
271 GROUPS => { 1 => 'Real-RA3', 2 => 'Audio' },
272 PROCESS_PROC => \&Image::ExifTool::Canon::ProcessSerialData,
273 VARS => { ID_LABEL => 'Sequence' },
274 FORMAT => 'int8u',
275 0 => { Name => 'Channels', Format => 'int16u' },
276 1 => { Name => 'Unknown', Format => 'int16u[3]', Unknown => 1 },
277 2 => { Name => 'BytesPerMinute', Format => 'int16u' },
278 3 => { Name => 'AudioBytes', Format => 'int32u' },
279 4 => { Name => 'TitleLen', Unknown => 1 },
280 5 => { Name => 'Title', Format => 'string[$val{4}]' },
281 6 => { Name => 'ArtistLen', Unknown => 1 },
282 7 => { Name => 'Artist', Format => 'string[$val{6}]', Groups => { 2 => 'Author' } },
283 8 => { Name => 'CopyrightLen', Unknown => 1 },
284 9 => { Name => 'Copyright', Format => 'string[$val{8}]', Groups => { 2 => 'Author' } },
285 10 => { Name => 'CommentLen', Unknown => 1 },
286 11 => { Name => 'Comment', Format => 'string[$val{10}]' },
287 );
288  
289 1 %Image::ExifTool::Real::AudioV4 = (
290 GROUPS => { 1 => 'Real-RA4', 2 => 'Audio' },
291 PROCESS_PROC => \&Image::ExifTool::Canon::ProcessSerialData,
292 VARS => { ID_LABEL => 'Sequence' },
293 FORMAT => 'int16u',
294 0 => { Name => 'FourCC1', Format => 'undef[4]', Unknown => 1 },
295 1 => { Name => 'AudioFileSize', Format => 'int32u', Unknown => 1 },
296 2 => { Name => 'Version2', Unknown => 1 },
297 3 => { Name => 'HeaderSize', Format => 'int32u', Unknown => 1 },
298 4 => { Name => 'CodecFlavorID', Unknown => 1 },
299 5 => { Name => 'CodedFrameSize', Format => 'int32u', Unknown => 1 },
300 6 => { Name => 'AudioBytes', Format => 'int32u' },
301 7 => { Name => 'BytesPerMinute', Format => 'int32u' },
302 8 => { Name => 'Unknown', Format => 'int32u', Unknown => 1 },
303 9 => { Name => 'SubPacketH', Unknown => 1 },
304 10 => 'AudioFrameSize',
305 11 => { Name => 'SubPacketSize', Unknown => 1 },
306 12 => { Name => 'Unknown', Unknown => 1 },
307 13 => 'SampleRate',
308 14 => { Name => 'Unknown', Unknown => 1 },
309 15 => 'BitsPerSample',
310 16 => 'Channels',
311 17 => { Name => 'FourCC2Len', Format => 'int8u', Unknown => 1 },
312 18 => { Name => 'FourCC2', Format => 'undef[4]', Unknown => 1 },
313 19 => { Name => 'FourCC3Len', Format => 'int8u', Unknown => 1 },
314 20 => { Name => 'FourCC3', Format => 'undef[4]', Unknown => 1 },
315 21 => { Name => 'Unknown', Format => 'int8u', Unknown => 1 },
316 22 => { Name => 'Unknown', Unknown => 1 },
317 23 => { Name => 'TitleLen', Format => 'int8u', Unknown => 1 },
318 24 => { Name => 'Title', Format => 'string[$val{23}]' },
319 25 => { Name => 'ArtistLen', Format => 'int8u', Unknown => 1 },
320 26 => { Name => 'Artist', Format => 'string[$val{25}]', Groups => { 2 => 'Author' } },
321 27 => { Name => 'CopyrightLen', Format => 'int8u', Unknown => 1 },
322 28 => { Name => 'Copyright', Format => 'string[$val{27}]', Groups => { 2 => 'Author' } },
323 29 => { Name => 'CommentLen', Format => 'int8u', Unknown => 1 },
324 30 => { Name => 'Comment', Format => 'string[$val{29}]' },
325 );
326  
327 1 %Image::ExifTool::Real::AudioV5 = (
328 GROUPS => { 1 => 'Real-RA5', 2 => 'Audio' },
329 PROCESS_PROC => \&Image::ExifTool::Canon::ProcessSerialData,
330 VARS => { ID_LABEL => 'Sequence' },
331 FORMAT => 'int16u',
332 0 => { Name => 'FourCC1', Format => 'undef[4]', Unknown => 1 },
333 1 => { Name => 'AudioFileSize', Format => 'int32u', Unknown => 1 },
334 2 => { Name => 'Version2', Unknown => 1 },
335 3 => { Name => 'HeaderSize', Format => 'int32u', Unknown => 1 },
336 4 => { Name => 'CodecFlavorID', Unknown => 1 },
337 5 => { Name => 'CodedFrameSize', Format => 'int32u', Unknown => 1 },
338 6 => { Name => 'AudioBytes', Format => 'int32u' },
339 7 => { Name => 'BytesPerMinute', Format => 'int32u' },
340 8 => { Name => 'Unknown', Format => 'int32u', Unknown => 1 },
341 9 => { Name => 'SubPacketH', Unknown => 1 },
342 10 => { Name => 'FrameSize', Unknown => 1 },
343 11 => { Name => 'SubPacketSize', Unknown => 1 },
344 12 => 'SampleRate',
345 13 => { Name => 'SampleRate2', Unknown => 1 },
346 14 => { Name => 'BitsPerSample', Format => 'int32u' },
347 15 => 'Channels',
348 16 => { Name => 'Genr', Format => 'int32u', Unknown => 1 },
349 17 => { Name => 'FourCC3', Format => 'undef[4]', Unknown => 1 },
350 );
351  
352 #------------------------------------------------------------------------------
353 # Process Real NameValueProperties
354 # Inputs: 0) ExifTool object reference, 1) dirInfo ref, 2) tag table ref
355 # Returns: 1 on success
356 sub ProcessRealProperties($$$)
357 1 ▶{
Subroutine ProcessRealProperties: called CC=12 SCAR=28.2
Pod undocumented
358 1 my ($et, $dirInfo, $tagTablePtr) = @_;
359 1 my $dataPt = $$dirInfo{DataPt};
360 1 my $dirLen = $$dirInfo{DirLen};
361 1 my $pos = $$dirInfo{DirStart};
362 1 my $verbose = $et->Options('Verbose');
363  
364 1 ▶ $verbose and $et->VerboseDir('RealProperties', undef, $dirLen);
Branch: 1 branch
BranchTrueFalseTotal
$verbose and $et->VerboseDir("RealProperties", undef, $dirLen) 0 1 1
365  
366 1 ▶ while ($pos + 6 <= $dirLen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pos + 6 <= $dirLen) 9 1 10
367  
368 # get property size and version
369 9 my ($size, $vers) = unpack("x${pos}Nn", $$dataPt);
370 9 ▶ last if $size < 6;
Branch: 1 branch
BranchTrueFalseTotal
if $size < 6 0 9 9
371 9 ▶ unless ($vers == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($vers == 0) 0 9 9
372 0 $pos += $size;
373 0 next;
374 }
375 9 $pos += 6;
376  
377 9 my $tagLen = unpack("x${pos}C", $$dataPt);
378 9 ++$pos;
379  
380 9 ▶ last if $pos + $tagLen > $dirLen;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $tagLen > $dirLen 0 9 9
381 9 my $tag = substr($$dataPt, $pos, $tagLen);
382 9 $pos += $tagLen;
383  
384 9 ▶ last if $pos + 6 > $dirLen;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + 6 > $dirLen 0 9 9
385 9 my ($type, $valLen) = unpack("x${pos}Nn", $$dataPt);
386 9 $pos += 6;
387  
388 9 ▶ last if $pos + $valLen > $dirLen;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $valLen > $dirLen 0 9 9
389 9 ▶ my $format = $propertyType{$type} || 'undef';
Condition50%1/2
$propertyType{$type} || 'undef'
l!l
90
MC/DC0%0/1
$propertyType{$type} || 'undef'
$propertyType{$type}
Truth table50%1/2
A
A= $propertyType{$type}
Aresult
11
00
390 9 my $count = int($valLen / Image::ExifTool::FormatSize($format));
391 9 my $val = ReadValue($dataPt, $pos, $format, $count, $dirLen-$pos);
392  
393 9 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
394 9 ▶ unless ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tagInfo) 0 9 9
395 0 my $tagName;
396 0 ($tagName = $tag) =~ s/\s+//g;
397 0 ▶ next unless $tagName =~ /^\w+$/; # ignore crazy names
Branch: 1 branch
BranchTrueFalseTotal
unless $tagName =~ /^\w+$/ 0 0 0
398 0 $tagInfo = { Name => ucfirst($tagName) };
399 0 AddTagToTable($tagTablePtr, $tag, $tagInfo);
400 }
401 9 ▶ if ($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) 0 9 9
402 $et->VerboseInfo($tag, $tagInfo,
403 Table => $tagTablePtr,
404 Value => $val,
405 DataPt => $dataPt,
406 Size => $valLen,
407 Start => $pos,
408 Addr => $pos + $$dirInfo{DataPos},
409 0 Format => $format,
410 Count => $count,
411 );
412 }
413 9 $et->FoundTag($tagInfo, $val);
414 9 $pos += $valLen;
415 }
416 1 return 1;
417 }
418  
419 #------------------------------------------------------------------------------
420 # Process Real metadata properties
421 # Inputs: 0) ExifTool object reference, 1) dirInfo ref, 2) tag table ref
422 # Returns: 1 on success
423 sub ProcessRealMeta($$$)
424 7 ▶{
Subroutine ProcessRealMeta: called CC=23 SCAR=35.8
Pod undocumented
425 7 my ($et, $dirInfo, $tagTablePtr) = @_;
426 7 my $dataPt = $$dirInfo{DataPt};
427 7 my $dataPos = $$dirInfo{DataPos};
428 7 my $pos = $$dirInfo{DirStart};
429 7 my $dirEnd = $pos + $$dirInfo{DirLen};
430 7 my $verbose = $et->Options('Verbose');
431 7 ▶ my $prefix = $$dirInfo{Prefix} || '';
Condition100%2/2
$dirInfo->{'Prefix'} || ''
l!l
52
MC/DC100%1/1
$dirInfo->{'Prefix'} || ''
$dirInfo->{'Prefix'}
Truth table100%2/2
A
A= $dirInfo->{'Prefix'}
Aresult
11
00
432 7 ▶ $prefix and $prefix .= '/';
Branch: 1 branch
BranchTrueFalseTotal
$prefix and $prefix .= '/' 5 2 7
433  
434 7 ▶ $verbose and $et->VerboseDir('RealMetadata', undef, $$dirInfo{DirLen});
Branch: 1 branch
BranchTrueFalseTotal
$verbose and $et->VerboseDir("RealMetadata", undef, $dirInfo->{"DirLen"}) 0 7 7
435  
436 7 for (;;) {
437 21 ▶ last if $pos + 28 > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + 28 > $dirEnd 7 14 21
438 # extract fixed-position metadata structure members
439 14 my ($size, $type, $flags, $valuePos, $subPropPos, $numSubProps, $nameLen)
440 = unpack("x${pos}N7", $$dataPt);
441 # make pointers relative to data start
442 14 $valuePos += $pos;
443 14 $subPropPos += $pos;
444 # validate what we have read so far
445 14 ▶ last if $pos + $size > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + $size > $dirEnd 0 14 14
446 14 ▶ last if $pos + 28 + $nameLen > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $pos + 28 + $nameLen > $dirEnd 0 14 14
447 14 ▶ last if $valuePos < $pos + 28 + $nameLen;
Branch: 1 branch
BranchTrueFalseTotal
if $valuePos < $pos + 28 + $nameLen 0 14 14
448 14 ▶ last if $valuePos + 4 > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $valuePos + 4 > $dirEnd 0 14 14
449 14 my $tag = substr($$dataPt, $pos + 28, $nameLen);
450 14 $tag =~ s/\0.*//s; # truncate at null
451 14 $tag = $prefix . $tag;
452 14 my $valueLen = unpack("x${valuePos}N", $$dataPt);
453 14 $valuePos += 4; # point at value itself
454 14 ▶ last if $valuePos + $valueLen > $dirEnd;
Branch: 1 branch
BranchTrueFalseTotal
if $valuePos + $valueLen > $dirEnd 0 14 14
455  
456 14 my $format = $metadataFormat{$type};
457 14 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
458 14 ▶ unless ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($tagInfo) 10 4 14
459 10 my $tagName = $tag;
460 10 $tagName =~ tr/A-Za-z0-9//dc;
461 10 $tagInfo = { Name => ucfirst($tagName) };
462 10 AddTagToTable($tagTablePtr, $tag, $tagInfo);
463 }
464 14 ▶ if ($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) 0 14 14
465 0 ▶ $format = 'undef' unless defined $format;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $format 0 0 0
466 0 $flags = Image::ExifTool::DecodeBits($flags, \%metadataFlag);
467 }
468 14 ▶ if ($valueLen and $format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($valueLen and $format) 9 5 14
Condition66%2/3
$valueLen and $format
!ll&&!rl&&r
059
MC/DC50%1/2
$valueLen and $format
$valueLen $format
Truth table66%2/3
A and B
A= $valueLenB= $format
ABresult
0X0
100
111
469 # (a flag can be 1 or 4 bytes)
470 9 ▶ if ($format eq 'flag') {
Branch: 2 branches
BranchTrueFalseTotal
if ($format eq 'flag') { } 0 9 9
elsif ($type == 7 and $tagInfo) { } 0 18 18
471 0 ▶ $format = ($valueLen == 4) ? 'int32u' : 'int8u';
Branch: 1 branch
BranchTrueFalseTotal
$valueLen == 4 ? : 0 0 0
472 ▶ } elsif ($type == 7 and $tagInfo) {
Condition33%1/3
$type == 7 and $tagInfo
!ll&&!rl&&r
900
MC/DC0%0/2
$type == 7 and $tagInfo
$type == 7 $tagInfo
Truth table33%1/3
A and B
A= $type == 7B= $tagInfo
ABresult
0X0
100
111
473 # add PrintConv and ValueConv for "date" type
474 0 ▶ $$tagInfo{ValueConv} or $$tagInfo{ValueConv} = q{
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo->{"ValueConv"} or $tagInfo->{"ValueConv"} = "\n \$val =~ /^(\\d{4})(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})/ ?\n sprintf(\"%.4d:%.2d:%.2d %.2d:%.2d:%.2d\",\$1,\$2,\$3,\$4,\$5,\$6) :\n \$val;\n " 0 0 0
475 $val =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ ?
476 sprintf("%.4d:%.2d:%.2d %.2d:%.2d:%.2d",$1,$2,$3,$4,$5,$6) :
477 $val;
478 };
479 0 ▶ $$tagInfo{PrintConv} or $$tagInfo{PrintConv} = '$self->ConvertDateTime($val)';
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo->{"PrintConv"} or $tagInfo->{"PrintConv"} = "\$self->ConvertDateTime(\$val)" 0 0 0
480 }
481 9 my $count = int($valueLen / Image::ExifTool::FormatSize($format));
482 9 my $val = ReadValue($dataPt, $valuePos, $format, $count, $dirEnd-$valuePos);
483 9 $et->HandleTag($tagTablePtr, $tag, $val,
484 DataPt => $dataPt,
485 DataPos => $dataPos,
486 Start => $valuePos,
487 Size => $valueLen,
488 Format => "type=$type, flags=$flags",
489 );
490 }
491 # extract sub-properties
492 14 ▶ if ($numSubProps) {
Branch: 1 branch
BranchTrueFalseTotal
if ($numSubProps) 6 8 14
493 6 my $dirStart = $valuePos + $valueLen + $numSubProps * 8;
494 6 my %dirInfo = (
495 DataPt => $dataPt,
496 DataPos => $dataPos,
497 DirStart => $dirStart,
498 DirLen => $pos + $size - $dirStart,
499 Prefix => $tag,
500 );
501 6 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
502 }
503 14 $pos += $size; # step to next Metadata structure
504 }
505 7 ▶ unless ($pos == $dirEnd) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pos == $dirEnd) 0 7 7
506 0 $et->Warn('Format error in Real Metadata');
507 0 return 0;
508 }
509 7 return 1;
510 }
511  
512 #------------------------------------------------------------------------------
513 # Read information frame a Real file
514 # Inputs: 0) ExifTool object reference, 1) Directory information reference
515 # Returns: 1 on success, 0 if this wasn't a valid Real file
516 sub ProcessReal($$)
517 3 ▶{
Subroutine ProcessReal: called CC=48 SCAR=47.4
Pod undocumented
518 3 my ($et, $dirInfo) = @_;
519 3 my $raf = $$dirInfo{RAF};
520 3 my ($buff, $tag, $vers, $extra, @mimeTypes, %dirCount);
521  
522 3 ▶ $raf->Read($buff, 8) == 8 or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($buff, 8) == 8 or return 0 3 0 3
523 3 ▶ $buff =~ m{^(\.RMF|\.ra\xfd|pnm://|rtsp://|http://)} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$buff =~ m[^(\.RMF|\.ra\xfd|pnm://|rtsp://|http://)] or return 0 3 0 3
524  
525 3 ▶ my $fast3 = $$et{OPTIONS}{FastScan} && $$et{OPTIONS}{FastScan} == 3;
Condition33%1/3
$et->{'OPTIONS'}{'FastScan'} && $et->{'OPTIONS'}{'FastScan'} == 3
!ll&&!rl&&r
300
MC/DC0%0/2
$et->{'OPTIONS'}{'FastScan'} && $et->{'OPTIONS'}{'FastScan'} == 3
$et->{'OPTIONS'}{'FastScan'} $et->{'OPTIONS'}{'FastScan'} == 3
Truth table33%1/3
A && B
A= $et->{'OPTIONS'}{'FastScan'}B= $et->{'OPTIONS'}{'FastScan'} == 3
ABresult
0X0
100
111
526 3 my ($type, $tagTablePtr);
527 3 ▶ if ($1 eq '.RMF') {
Branch: 2 branches
BranchTrueFalseTotal
if ($1 eq '.RMF') { } 1 2 3
elsif ($1 eq ".ra\375") { } 1 1 2
528 1 $tagTablePtr = GetTagTable('Image::ExifTool::Real::Media');
529 1 $type = 'RM';
530 } elsif ($1 eq ".ra\xfd") {
531 1 $tagTablePtr = GetTagTable('Image::ExifTool::Real::Audio');
532 1 $type = 'RA';
533 } else {
534 1 $tagTablePtr = GetTagTable('Image::ExifTool::Real::Metafile');
535 1 my $ext = $$et{FILE_EXT};
536 1 ▶ $type = ($ext and $ext eq 'RPM') ? 'RPM' : 'RAM';
Branch: 1 branch
BranchTrueFalseTotal
$ext && $ext eq 'RPM' ? : 0 1 1
Condition33%1/3
$ext and $ext eq "RPM"
!ll&&!rl&&r
010
MC/DC0%0/2
$ext and $ext eq "RPM"
$ext $ext eq "RPM"
Truth table33%1/3
A and B
A= $extB= $ext eq "RPM"
ABresult
0X0
100
111
537 1 require Image::ExifTool::PostScript;
538 1 ▶ local $/ = Image::ExifTool::PostScript::GetInputRecordSeparator($raf) || "\n";
Condition50%1/2
&Image::ExifTool::PostScript::GetInputRecordSeparator($raf) || "\n"
l!l
01
MC/DC0%0/1
&Image::ExifTool::PostScript::GetInputRecordSeparator($raf) || "\n"
&Image::ExifTool::PostScript::GetInputRecordSeparator($raf)
Truth table50%1/2
A
A= &Image::ExifTool::PostScript::GetInputRecordSeparator($raf)
Aresult
11
00
539 1 $raf->Seek(0,0);
540 1 ▶ while ($raf->ReadLine($buff)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->ReadLine($buff)) 1 1 2
541 1 ▶ last if length $buff > 256;
Branch: 1 branch
BranchTrueFalseTotal
if length $buff > 256 0 1 1
542 1 ▶ next unless $buff ;
Branch: 1 branch
BranchTrueFalseTotal
unless $buff 0 1 1
543 1 chomp $buff;
544 1 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 1 0 1
545 # must be a Real file type if protocol is http
546 1 ▶ return 0 if $buff =~ /^http/ and $buff !~ /\.(ra|rm|rv|rmvb|smil)$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $buff =~ /^http/ and not $buff =~ /\.(ra|rm|rv|rmvb|smil)$/i 0 1 1
Condition33%1/3
$buff =~ /^http/ and not $buff =~ /\.(ra|rm|rv|rmvb|smil)$/i
!ll&&!rl&&r
100
MC/DC0%0/2
$buff =~ /^http/ and not $buff =~ /\.(ra|rm|rv|rmvb|smil)$/i
$buff =~ /^http/ not $buff =~ /\.(ra|rm|rv|rmvb|smil)$/i
Truth table33%1/3
A and not(B)
A= $buff =~ /^http/B= not $buff =~ /\.(ra|rm|rv|rmvb|smil)$/i
ABresult
0X0
100
111
547 1 $et->SetFileType($type);
548 1 ▶ return 1 if $fast3;
Branch: 1 branch
BranchTrueFalseTotal
if $fast3 0 1 1
549 1 undef $type;
550 }
551 # save URL or Text from RAM file
552 1 ▶ my $tag = $buff =~ m{^[a-z]{3,4}://} ? 'url' : 'txt';
Branch: 1 branch
BranchTrueFalseTotal
$buff =~ m[^[a-z]{3,4}://] ? : 1 0 1
553 1 $et->HandleTag($tagTablePtr, $tag, $buff);
554 }
555 1 return 1;
556 }
557  
558 2 $et->SetFileType($type);
559 2 ▶ return 1 if $fast3;
Branch: 1 branch
BranchTrueFalseTotal
if $fast3 0 2 2
560 2 SetByteOrder('MM');
561 2 my $verbose = $et->Options('Verbose');
562 #
563 # Process RealAudio file
564 #
565 2 ▶ if ($type eq 'RA') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "RA") 1 1 2
566 1 ($vers, $extra) = unpack('x4nn', $buff);
567 1 $tag = ".ra$vers";
568 1 my $fpos = $raf->Tell();
569 1 ▶ unless ($raf->Read($buff, 512)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf->Read($buff, 512)) 0 1 1
570 0 $et->Warn('Error reading audio header');
571 0 return 1;
572 }
573 1 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
574 1 ▶ if ($verbose > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose > 2) 0 1 1
575 0 $et->VerboseInfo($tag, $tagInfo, DataPt => \$buff, DataPos => $fpos);
576 }
577 1 ▶ if ($tagInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo) { } 1 0 1
578 1 my $subTablePtr = GetTagTable($tagInfo->{SubDirectory}->{TagTable});
579 1 my %dirInfo = (
580 DataPt => \$buff,
581 DataPos => $fpos,
582 DirLen => length $buff,
583 DirStart => 0,
584 );
585 1 $et->ProcessDirectory(\%dirInfo, $subTablePtr);
586 } else {
587 0 $et->Warn('Unsupported RealAudio version');
588 }
589 1 return 1;
590 }
591 #
592 # Process RealMedia file
593 #
594 # skip the rest of the RM header
595 1 my $size = unpack('x4N', $buff);
596 1 ▶ unless ($raf->Seek($size - 8, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf->Seek($size - 8, 1)) 0 1 1
597 0 $et->Warn('Error seeking in file');
598 0 return 0;
599 }
600  
601 # Process RealMedia chunks
602 1 for (;;) {
603 6 ▶ $raf->Read($buff, 10) == 10 or last;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($buff, 10) == 10 or last 5 1 6
604 5 ($tag, $size, $vers) = unpack('a4Nn', $buff);
605 5 ▶ last if $tag eq "\0\0\0\0";
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "\0\0\0\0" 0 5 5
606 5 ▶ if ($verbose) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose) { } 0 5 5
607 0 $et->VPrint(0, "$tag chunk ($size bytes):\n");
608 } else {
609 5 ▶ last if $tag eq 'DATA'; # stop normal parsing at DATA tag
Branch: 1 branch
BranchTrueFalseTotal
if $tag eq "DATA" 0 5 5
610 }
611 5 ▶ if ($size & 0x80000000 or $size < 10) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size & 2147483648 or $size < 10) 0 5 5
Condition33%1/3
$size & 2147483648 or $size < 10
l!l&&r!l&&!r
005
MC/DC0%0/2
$size & 2147483648 or $size < 10
$size & 2147483648 $size < 10
Truth table33%1/3
A or B
A= $size & 2147483648B= $size < 10
ABresult
1X1
011
000
612 0 $et->Warn('Bad chunk header');
613 0 last;
614 }
615 5 my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag);
616 5 ▶ if ($tagInfo and $$tagInfo{SubDirectory}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo and $tagInfo->{'SubDirectory'}) { } 4 1 5
Condition66%2/3
$tagInfo and $tagInfo->{"SubDirectory"}
!ll&&!rl&&r
104
MC/DC50%1/2
$tagInfo and $tagInfo->{"SubDirectory"}
$tagInfo $tagInfo->{"SubDirectory"}
Truth table66%2/3
A and B
A= $tagInfoB= $tagInfo->{"SubDirectory"}
ABresult
0X0
100
111
617 4 my $fpos = $raf->Tell();
618 4 ▶ unless ($raf->Read($buff, $size-10) == $size-10) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf->Read($buff, $size - 10) == $size - 10) 0 4 4
619 0 $et->Warn("Error reading $tag chunk");
620 0 last;
621 }
622 4 ▶ if ($verbose > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verbose > 2) 0 4 4
623 0 $et->VerboseInfo($tag, $tagInfo, DataPt => \$buff, DataPos => $fpos);
624 }
625 4 my $subTablePtr = GetTagTable($tagInfo->{SubDirectory}->{TagTable});
626 4 my %dirInfo = (
627 DataPt => \$buff,
628 DataPos => $fpos,
629 DirLen => length $buff,
630 DirStart => 0,
631 );
632 4 ▶ if ($dirCount{$tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dirCount{$tag}) { } 1 3 4
633 1 $$et{SET_GROUP1} = '+' . ++$dirCount{$tag};
634 } else {
635 3 $dirCount{$tag} = 1;
636 }
637 4 $et->ProcessDirectory(\%dirInfo, $subTablePtr);
638 4 delete $$et{SET_GROUP1};
639 # keep track of stream MIME types
640 4 my $mime = $$et{RealStreamMime};
641 4 ▶ if ($mime) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mime) 2 2 4
642 2 delete $$et{RealStreamMime};
643 2 $mime =~ s/\0.*//s;
644 2 ▶ push @mimeTypes, $mime unless $mime =~ /^logical-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $mime =~ /^logical-/ 1 1 2
645 }
646 } else {
647 1 ▶ unless ($raf->Seek($size-10, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($raf->Seek($size - 10, 1)) 0 1 1
648 0 $et->Warn('Error seeking in file');
649 0 last;
650 }
651 }
652 }
653 # override MIMEType with stream MIME type if we only have one stream
654 1 ▶ if (@mimeTypes == 1 and length $mimeTypes[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@mimeTypes == 1 and length $mimeTypes[0]) 1 0 1
Condition33%1/3
@mimeTypes == 1 and length $mimeTypes[0]
!ll&&!rl&&r
001
MC/DC0%0/2
@mimeTypes == 1 and length $mimeTypes[0]
@mimeTypes == 1 length $mimeTypes[0]
Truth table33%1/3
A and B
A= @mimeTypes == 1B= length $mimeTypes[0]
ABresult
0X0
100
111
655 1 $$et{VALUE}{MIMEType} = $mimeTypes[0];
656 1 $et->VPrint(0, " MIMEType = $mimeTypes[0]\n");
657 }
658 #
659 # Process footer containing Real metadata and ID3 information
660 #
661 1 ▶ if ($raf->Seek(-140, 2) and $raf->Read($buff, 12) == 12 and $buff =~ /^RMJE/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek(-140, 2) and $raf->Read($buff, 12) == 12 and $buff =~ /^RMJE/) 1 0 1
Condition33%2/6
$raf->Seek(-140, 2) and $raf->Read($buff, 12) == 12 and $buff =~ /^RMJE/
!ll&&!rl&&r
001
$raf->Seek(-140, 2) and $raf->Read($buff, 12) == 12
!ll&&!rl&&r
001
MC/DC0%0/3
$raf->Seek(-140, 2) and $raf->Read($buff, 12) == 12 and $buff =~ /^RMJE/
$raf->Seek(-140, 2) $raf->Read($buff, 12) == 12 $buff =~ /^RMJE/
Truth table25%1/4
A and B and C
A= $raf->Seek(-140, 2)B= $raf->Read($buff, 12) == 12C= $buff =~ /^RMJE/
ABCresult
0XX0
10X0
1100
1111
662 1 my $metaSize = unpack('x8N', $buff);
663 1 ▶ if ($raf->Seek(-$metaSize-12, 1) and
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek(-$metaSize - 12, 1) and $raf->Read($buff, $metaSize) == $metaSize and $buff =~ /^RJMD/) { } 1 0 1
Condition33%2/6
$raf->Seek(-$metaSize - 12, 1) and $raf->Read($buff, $metaSize) == $metaSize and $buff =~ /^RJMD/
!ll&&!rl&&r
001
$raf->Seek(-$metaSize - 12, 1) and $raf->Read($buff, $metaSize) == $metaSize
!ll&&!rl&&r
001
MC/DC0%0/3
$raf->Seek(-$metaSize - 12, 1) and $raf->Read($buff, $metaSize) == $metaSize and $buff =~ /^RJMD/
$raf->Seek(-$metaSize - 12, 1) $raf->Read($buff, $metaSize) == $metaSize $buff =~ /^RJMD/
Truth table25%1/4
A and B and C
A= $raf->Seek(-$metaSize - 12, 1)B= $raf->Read($buff, $metaSize) == $metaSizeC= $buff =~ /^RJMD/
ABCresult
0XX0
10X0
1100
1111
664 $raf->Read($buff, $metaSize) == $metaSize and
665 $buff =~ /^RJMD/)
666 {
667 1 my %dirInfo = (
668 DataPt => \$buff,
669 DataPos => $raf->Tell() - $metaSize,
670 DirStart => 8,
671 DirLen => length($buff) - 8,
672 );
673 1 my $tagTablePtr = GetTagTable('Image::ExifTool::Real::Metadata');
674 1 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
675 } else {
676 0 $et->Warn('Bad metadata footer');
677 }
678 1 ▶ if ($raf->Seek(-128, 2) and $raf->Read($buff, 128) == 128 and $buff =~ /^TAG/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($raf->Seek(-128, 2) and $raf->Read($buff, 128) == 128 and $buff =~ /^TAG/) 1 0 1
Condition33%2/6
$raf->Seek(-128, 2) and $raf->Read($buff, 128) == 128 and $buff =~ /^TAG/
!ll&&!rl&&r
001
$raf->Seek(-128, 2) and $raf->Read($buff, 128) == 128
!ll&&!rl&&r
001
MC/DC0%0/3
$raf->Seek(-128, 2) and $raf->Read($buff, 128) == 128 and $buff =~ /^TAG/
$raf->Seek(-128, 2) $raf->Read($buff, 128) == 128 $buff =~ /^TAG/
Truth table25%1/4
A and B and C
A= $raf->Seek(-128, 2)B= $raf->Read($buff, 128) == 128C= $buff =~ /^TAG/
ABCresult
0XX0
10X0
1100
1111
679 1 $et->VPrint(0, "ID3v1:\n");
680 1 my %dirInfo = (
681 DataPt => \$buff,
682 DirStart => 0,
683 DirLen => length($buff),
684 );
685 1 my $tagTablePtr = GetTagTable('Image::ExifTool::ID3::v1');
686 1 $et->ProcessDirectory(\%dirInfo, $tagTablePtr);
687 }
688 }
689 1 return 1;
690 }
691  
692 1 1; # end
693  
694 __END__
« Image/ExifTool/Kodak.pm ↑ Summary Image/ExifTool/Pentax.pm »