Info/RIFF.pm

filter: Statementstmt 100% 70 / 70 Branchbran 63.1% 24 / 38 Conditioncond 42.8% 6 / 14 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 77.8% 109 / 140 CC 25 SCAR 29.8
CC
25
Cov
82%
probe
27.9
expectedsize
2.0
init
2.0
CRAP 19.7
« Info/ASF.pm ↑ Summary Info/MPEG/System.pm »
1 package Video::Info::RIFF;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 our $VERSION = '1.07';
5  
6 2 ▶use base qw(Video::Info);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #is this reasonable? big fudge factor here.
9 2 ▶use constant MAX_HEADER_BYTES => 10240;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 use Class::MakeMethods::Emulator::MethodMaker
12 2 ▶ get_set => [qw( fourcc )],
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ;
14  
15 2 ▶sub init {
Subroutine init: called CC=2 SCAR=6.9
Pod undocumented
16 2 my $self = shift;
17 2 my %param = @_;
18 2 $self->init_attributes(@_);
19 2 ▶ $self->header_size($param{-headersize} || MAX_HEADER_BYTES);
Condition100%2/2
$param{'-headersize'} || 10240
l!l
11
MC/DC100%1/1
$param{'-headersize'} || 10240
$param{'-headersize'}
Truth table100%2/2
A
A= $param{'-headersize'}
Aresult
11
00
20 2 return $self;
21 }
22  
23 ##------------------------------------------------------------------------
24 ## header_size()
25 ##
26 ## Set the header size. Hrm, should this be in the accessor method
27 ## closures above?
28 ##------------------------------------------------------------------------
29 5 ▶sub header_size {
Subroutine header_size: called CC=2 SCAR=6.9
Pod undocumented
30 5 my($self,$arg) = @_;
31 5 ▶ return $self->{header_size} unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 3 2 5
32 2 $self->{header_size} = $arg;
33 }
34  
35 3 ▶sub expectedsize {
Subroutine expectedsize: called CC=2 SCAR=7.1
Pod undocumented
36 3 my($self,$arg) = @_;
37 3 ▶ return $self->{expectedsize} unless defined $arg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $arg 0 3 3
38 3 $self->{expectedsize} = $arg;
39 }
40  
41 ##------------------------------------------------------------------------
42 ## probe()
43 ##
44 ## Obtain the filehandle from Video::Info and extract the properties from
45 ## the RIFF structure.
46 ##------------------------------------------------------------------------
47 3 ▶sub probe {
Subroutine probe: called CC=22 SCAR=33.3
Pod undocumented
48 3 my $self = shift;
49  
50 3 my $fh = $self->handle; ## inherited from Video::Info
51  
52 3 my $type;
53 3 ▶ sysread($fh,$type,12) or die "probe(): can't read 12 bytes: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
sysread $fh, $type, 12 or die "probe(): can't read 12 bytes: $!\n" 3 0 3
54  
55 3 ▶ (warn "probe(): doesn't look like RIFF data" and return 0)
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^(RIFF)/ or $type =~ /^(AVI) / 0 3 3
Condition25%2/8
$type =~ /^(RIFF)/ || $type =~ /^(AVI) / || warn(q[probe(): doesn't look like RIFF data]) && (return 0)
l!l&&r!l&&!r
300
$type =~ /^(RIFF)/ or $type =~ /^(AVI) /
l!l&&r!l&&!r
300
warn "probe(): doesn't look like RIFF data" and return 0
!ll
00
MC/DC0%0/3
$type =~ /^(RIFF)/ || $type =~ /^(AVI) / || warn(q[probe(): doesn't look like RIFF data]) && (return 0)
$type =~ /^(RIFF)/ $type =~ /^(AVI) / warn "probe(): doesn't look like RIFF data"
Truth table25%1/4
A or B || C
A= $type =~ /^(RIFF)/B= $type =~ /^(AVI) /C= warn "probe(): doesn't look like RIFF data"
ABCresult
1XX1
01X1
0011
0000
56 if( ($type !~ /^(RIFF)/) && ($type !~ /^(AVI) /) );
57 3 $self->type( $1 );
58  
59 3 $self->expectedsize(unpack("V",substr($type,4,4)));
60  
61 #onward
62 3 my $hdrl_data = undef;
63  
64 3 ▶ while ( !$hdrl_data ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($hdrl_data) 3 3 6
65 3 my $byte;
66 3 ▶ sysread($fh,$byte,8) or die "probe(): can't read 8 bytes: $!";
Branch: 1 branch
BranchTrueFalseTotal
sysread $fh, $byte, 8 or die "probe(): can't read 8 bytes: $!" 3 0 3
67 3 ▶ if ( substr( $byte, 0, 4 ) eq 'LIST' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($byte, 0, 4) eq 'LIST') { } 3 0 3
elsif ($byte eq 'idx1') { } 0 0 0
68 3 ▶ sysread( $fh, $byte, 4 ) or die "probe() can't read 4 bytes: $!\n";
Branch: 1 branch
BranchTrueFalseTotal
sysread $fh, $byte, 4 or die "probe() can't read 4 bytes: $!\n" 3 0 3
69
70 3 ▶ if ( substr( $byte, 0, 4 ) eq 'hdrl' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (substr($byte, 0, 4) eq 'hdrl') { } 3 0 3
elsif ($byte eq 'movi') { } 0 0 0
71 3 sysread( $fh, $hdrl_data, $self->header_size );
72 } elsif ( $byte eq 'movi' ) {
73 ### noop
74 }
75 } elsif ( $byte eq 'idx1' ) {
76 ### noop
77 }
78 }
79
80 3 my $last_tag = 0;
81 3 ▶ for ( my $i=0; $i < length($hdrl_data); $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $hdrl_data) 30720 3 30723
82
83 30720 my $t = $i;
84 30720 my $window = substr( $hdrl_data, $t, 4 );
85
86 30720 ▶ if ( $window eq 'strh' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($window eq 'strh') { } 6 30714 30720
elsif ($window eq 'strf') { } 6 30708 30714
87  
88 6 $t += 8;
89 6 $window = substr( $hdrl_data, $t, 4 );
90
91 6 ▶ if ( $window eq 'vids' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($window eq 'vids') { } 3 3 6
elsif ($window eq 'auds') { } 3 0 3
92 3 $self->fourcc(substr($hdrl_data,$t+4,4));
93 3 $self->scale(unpack("V",substr($hdrl_data,$t+20,4)));
94 3 $self->vrate(unpack("V",substr($hdrl_data,$t+24,4)));
95 3 $self->fps($self->vrate / $self->scale);
96 3 $self->vframes(unpack("V",substr($hdrl_data,$t+32,4)));
97 3 ▶ $self->vstreams( ($self->vstreams || 0) + 1 );;
Condition50%1/2
$self->vstreams || 0
l!l
03
MC/DC0%0/1
$self->vstreams || 0
$self->vstreams
Truth table50%1/2
A
A= $self->vstreams
Aresult
11
00
98
99 3 ▶ $self->duration($self->vframes / $self->fps) if $self->fps;
Branch: 1 branch
BranchTrueFalseTotal
if $self->fps 3 0 3
100  
101 3 $last_tag = 1;
102
103 } elsif($window eq 'auds') {
104 3 ▶ $self->astreams( ($self->astreams || 0) + 1);
Condition50%1/2
$self->astreams || 0
l!l
03
MC/DC0%0/1
$self->astreams || 0
$self->astreams
Truth table50%1/2
A
A= $self->astreams
Aresult
11
00
105 3 $last_tag = 2;
106
107 }
108 }
109 elsif ( $window eq 'strf' ) {
110
111 6 $t += 8;
112 6 $window = substr( $hdrl_data, $t, 4 );
113
114 6 ▶ if ( $last_tag == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($last_tag == 1) { } 3 3 6
elsif ($last_tag == 2) { } 3 0 3
115 3 $self->width(unpack("V",substr($hdrl_data,$t+4,4)));
116 3 $self->height(unpack("V",substr($hdrl_data,$t+8,4)));
117 3 $self->vcodec(substr($hdrl_data,$t+16,4));
118
119 } elsif( $last_tag == 2 ) {
120 3 $self->acodecraw(unpack("v",substr($hdrl_data,$t,2)));
121 3 $self->achans(unpack("v",substr($hdrl_data,$t+2,2)));
122 3 $self->afrequency(unpack("v",substr($hdrl_data,$t+4,2)));
123 3 $self->arate(
124 8 * unpack("V",substr($hdrl_data,$t+8,4))
125 );
126
127 }
128
129 6 $last_tag = 0;
130 }
131 }
132 3 return 1;
133 }
134  
135 2 1;
136  
137 __END__
« Info/ASF.pm ↑ Summary Info/MPEG/System.pm »