Image/ExifTool/MOI.pm

filter: Statementstmt 100% 28 / 28 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 80.8% 38 / 47 CC 6 SCAR 12.2
CC
6
Cov
85%
ProcessMOI
5.4
__ANON__
2.0
BEGIN
1.0
CRAP 3.4
« Image/ExifTool/DPX.pm ↑ Summary Image/ExifTool/LIF.pm »
1 #------------------------------------------------------------------------------
2 # File: MOI.pm
3 #
4 # Description: Read MOI meta information
5 #
6 # Revisions: 2014/12/15 - P. Harvey Created
7 #
8 # References: 1) https://en.wikipedia.org/wiki/MOI_(file_format)
9 #------------------------------------------------------------------------------
10  
11 package Image::ExifTool::MOI;
12  
13 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Image::ExifTool qw(:DataAccess :Utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 1 $VERSION = '1.02';
18  
19 # MOI tags (ref 1)
20 %Image::ExifTool::MOI::Main = (
21 GROUPS => { 2 => 'Video' },
22 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
23 NOTES => q{
24 MOI files store information about associated MOD or TOD files, and are
25 written by some JVC, Canon and Panasonic camcorders.
26 },
27 0x00 => { Name => 'MOIVersion', Format => 'string[2]' },
28 # 0x02 => { Name => 'MOIFileSize', Format => 'int32u' },
29 0x06 => {
30 Name => 'DateTimeOriginal',
31 Description => 'Date/Time Original',
32 Format => 'undef[8]',
33 Groups => { 2 => 'Time' },
34 1 ▶ ValueConv => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
35 1 my $val = shift;
36 1 ▶ return undef unless length($val) >= 8;
Branch: 1 branch
BranchTrueFalseTotal
unless length $val >= 8 0 1 1
37 1 my @v = unpack('nCCCCn', $val);
38 1 $v[5] /= 1000;
39 1 return sprintf('%.4d:%.2d:%.2d %.2d:%.2d:%06.3f', @v);
40 },
41 1 PrintConv => '$self->ConvertDateTime($val)',
42 },
43 0x0e => {
44 Name => 'Duration',
45 Format => 'int32u',
46 ValueConv => '$val / 1000',
47 PrintConv => 'ConvertDuration($val)',
48 },
49 0x80 => {
50 Name => 'AspectRatio',
51 Format => 'int8u',
52 PrintConv => q{
53 my $lo = ($val & 0x0f);
54 my $hi = ($val >> 4);
55 my $aspect;
56 if ($lo < 2) {
57 $aspect = '4:3';
58 } elsif ($lo == 4 or $lo == 5) {
59 $aspect = '16:9';
60 } else {
61 $aspect = 'Unknown';
62 }
63 if ($hi == 4) {
64 $aspect .= ' NTSC';
65 } elsif ($hi == 5) {
66 $aspect .= ' PAL';
67 }
68 return $aspect;
69 },
70 },
71 0x84 => {
72 Name => 'AudioCodec',
73 Format => 'int16u',
74 Groups => { 2 => 'Audio' },
75 PrintHex => 1,
76 PrintConv => {
77 0x00c1 => 'AC3',
78 0x4001 => 'MPEG',
79 },
80 },
81 0x86 => {
82 Name => 'AudioBitrate',
83 Format => 'int8u',
84 Groups => { 2 => 'Audio' },
85 ValueConv => '$val * 16000 + 48000',
86 PrintConv => 'ConvertBitrate($val)',
87 },
88 0xda => {
89 Name => 'VideoBitrate',
90 Format => 'int16u',
91 PrintHex => 1,
92 ValueConv => {
93 0x5896 => '8500000',
94 0x813d => '5500000',
95 },
96 PrintConv => 'ConvertBitrate($val)',
97 },
98 );
99  
100 #------------------------------------------------------------------------------
101 # Validate and extract metadata from MOI file
102 # Inputs: 0) ExifTool ref, 1) dirInfo ref
103 # Returns: 1 on success, 0 if this wasn't a valid MOI file
104 sub ProcessMOI($$)
105 1 ▶{
Subroutine ProcessMOI: called CC=5 SCAR=16.8
Pod undocumented
106 1 my ($et, $dirInfo) = @_;
107 1 my $raf = $$dirInfo{RAF};
108 1 my $buff;
109 # read enough to allow skipping over run-in if it exists
110 1 ▶ $raf->Read($buff, 256) == 256 and $buff =~ /^V6/ or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$raf->Read($buff, 256) == 256 and $buff =~ /^V6/ or return 0 1 0 1
Condition33%1/3
$raf->Read($buff, 256) == 256 and $buff =~ /^V6/
!ll&&!rl&&r
001
MC/DC0%0/2
$raf->Read($buff, 256) == 256 and $buff =~ /^V6/
$raf->Read($buff, 256) == 256 $buff =~ /^V6/
Truth table33%1/3
A and B
A= $raf->Read($buff, 256) == 256B= $buff =~ /^V6/
ABresult
0X0
100
111
111 1 ▶ if (defined $$et{VALUE}{FileSize}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $et->{"VALUE"}{"FileSize"}) 1 0 1
112 1 my $size = unpack('x2N', $buff);
113 1 ▶ $size == $$et{VALUE}{FileSize} or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$size == $et->{"VALUE"}{"FileSize"} or return 0 1 0 1
114 }
115 1 $et->SetFileType();
116 1 SetByteOrder('MM');
117 1 my $tagTablePtr = GetTagTable('Image::ExifTool::MOI::Main');
118 1 return $et->ProcessBinaryData({ DataPt => \$buff }, $tagTablePtr);
119 }
120  
121 1 1; # end
122  
123 __END__
« Image/ExifTool/DPX.pm ↑ Summary Image/ExifTool/LIF.pm »