line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Video::Info::RIFF; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
7572
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
134
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.07'; |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use base qw(Video::Info); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
619
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#is this reasonable? big fudge factor here. |
9
|
2
|
|
|
2
|
|
16
|
use constant MAX_HEADER_BYTES => 10240; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
136
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Class::MakeMethods::Emulator::MethodMaker |
12
|
2
|
|
|
|
|
119
|
get_set => [qw( fourcc )], |
13
|
2
|
|
|
2
|
|
11
|
; |
|
2
|
|
|
|
|
11
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub init { |
16
|
2
|
|
|
2
|
0
|
4
|
my $self = shift; |
17
|
2
|
|
|
|
|
9
|
my %param = @_; |
18
|
2
|
|
|
|
|
16
|
$self->init_attributes(@_); |
19
|
2
|
|
100
|
|
|
30
|
$self->header_size($param{-headersize} || MAX_HEADER_BYTES); |
20
|
2
|
|
|
|
|
6
|
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
|
|
|
|
|
|
|
sub header_size { |
30
|
5
|
|
|
5
|
0
|
9
|
my($self,$arg) = @_; |
31
|
5
|
100
|
|
|
|
94
|
return $self->{header_size} unless defined $arg; |
32
|
2
|
|
|
|
|
7
|
$self->{header_size} = $arg; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub expectedsize { |
36
|
3
|
|
|
3
|
0
|
8
|
my($self,$arg) = @_; |
37
|
3
|
50
|
|
|
|
24
|
return $self->{expectedsize} unless defined $arg; |
38
|
3
|
|
|
|
|
7
|
$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
|
|
|
|
|
|
|
sub probe { |
48
|
3
|
|
|
3
|
0
|
206
|
my $self = shift; |
49
|
|
|
|
|
|
|
|
50
|
3
|
|
|
|
|
11
|
my $fh = $self->handle; ## inherited from Video::Info |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
20
|
my $type; |
53
|
3
|
50
|
|
|
|
46
|
sysread($fh,$type,12) or die "probe(): can't read 12 bytes: $!\n"; |
54
|
|
|
|
|
|
|
|
55
|
3
|
0
|
0
|
|
|
18
|
(warn "probe(): doesn't look like RIFF data" and return 0) |
|
|
|
33
|
|
|
|
|
56
|
|
|
|
|
|
|
if( ($type !~ /^(RIFF)/) && ($type !~ /^(AVI) /) ); |
57
|
3
|
|
|
|
|
97
|
$self->type( $1 ); |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
41
|
$self->expectedsize(unpack("V",substr($type,4,4))); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
#onward |
62
|
3
|
|
|
|
|
5
|
my $hdrl_data = undef; |
63
|
|
|
|
|
|
|
|
64
|
3
|
|
|
|
|
9
|
while ( !$hdrl_data ) { |
65
|
3
|
|
|
|
|
5
|
my $byte; |
66
|
3
|
50
|
|
|
|
22
|
sysread($fh,$byte,8) or die "probe(): can't read 8 bytes: $!"; |
67
|
3
|
50
|
|
|
|
13
|
if ( substr( $byte, 0, 4 ) eq 'LIST' ) { |
|
|
0
|
|
|
|
|
|
68
|
3
|
50
|
|
|
|
22
|
sysread( $fh, $byte, 4 ) or die "probe() can't read 4 bytes: $!\n"; |
69
|
|
|
|
|
|
|
|
70
|
3
|
50
|
|
|
|
18
|
if ( substr( $byte, 0, 4 ) eq 'hdrl' ) { |
|
|
0
|
|
|
|
|
|
71
|
3
|
|
|
|
|
10
|
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
|
|
|
|
|
5
|
my $last_tag = 0; |
81
|
3
|
|
|
|
|
45
|
for ( my $i=0; $i < length($hdrl_data); $i++ ) { |
82
|
|
|
|
|
|
|
|
83
|
30720
|
|
|
|
|
41749
|
my $t = $i; |
84
|
30720
|
|
|
|
|
35136
|
my $window = substr( $hdrl_data, $t, 4 ); |
85
|
|
|
|
|
|
|
|
86
|
30720
|
100
|
|
|
|
138888
|
if ( $window eq 'strh' ) { |
|
|
100
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
6
|
|
|
|
|
10
|
$t += 8; |
89
|
6
|
|
|
|
|
12
|
$window = substr( $hdrl_data, $t, 4 ); |
90
|
|
|
|
|
|
|
|
91
|
6
|
100
|
|
|
|
20
|
if ( $window eq 'vids' ) { |
|
|
50
|
|
|
|
|
|
92
|
3
|
|
|
|
|
95
|
$self->fourcc(substr($hdrl_data,$t+4,4)); |
93
|
3
|
|
|
|
|
114
|
$self->scale(unpack("V",substr($hdrl_data,$t+20,4))); |
94
|
3
|
|
|
|
|
97
|
$self->vrate(unpack("V",substr($hdrl_data,$t+24,4))); |
95
|
3
|
|
|
|
|
104
|
$self->fps($self->vrate / $self->scale); |
96
|
3
|
|
|
|
|
122
|
$self->vframes(unpack("V",substr($hdrl_data,$t+32,4))); |
97
|
3
|
|
50
|
|
|
92
|
$self->vstreams( ($self->vstreams || 0) + 1 );; |
98
|
|
|
|
|
|
|
|
99
|
3
|
50
|
|
|
|
192
|
$self->duration($self->vframes / $self->fps) if $self->fps; |
100
|
|
|
|
|
|
|
|
101
|
3
|
|
|
|
|
150
|
$last_tag = 1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} elsif($window eq 'auds') { |
104
|
3
|
|
50
|
|
|
84
|
$self->astreams( ($self->astreams || 0) + 1); |
105
|
3
|
|
|
|
|
120
|
$last_tag = 2; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
elsif ( $window eq 'strf' ) { |
110
|
|
|
|
|
|
|
|
111
|
6
|
|
|
|
|
11
|
$t += 8; |
112
|
6
|
|
|
|
|
11
|
$window = substr( $hdrl_data, $t, 4 ); |
113
|
|
|
|
|
|
|
|
114
|
6
|
100
|
|
|
|
18
|
if ( $last_tag == 1 ) { |
|
|
50
|
|
|
|
|
|
115
|
3
|
|
|
|
|
93
|
$self->width(unpack("V",substr($hdrl_data,$t+4,4))); |
116
|
3
|
|
|
|
|
97
|
$self->height(unpack("V",substr($hdrl_data,$t+8,4))); |
117
|
3
|
|
|
|
|
159
|
$self->vcodec(substr($hdrl_data,$t+16,4)); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} elsif( $last_tag == 2 ) { |
120
|
3
|
|
|
|
|
192
|
$self->acodecraw(unpack("v",substr($hdrl_data,$t,2))); |
121
|
3
|
|
|
|
|
106
|
$self->achans(unpack("v",substr($hdrl_data,$t+2,2))); |
122
|
3
|
|
|
|
|
4236
|
$self->afrequency(unpack("v",substr($hdrl_data,$t+4,2))); |
123
|
3
|
|
|
|
|
113
|
$self->arate( |
124
|
|
|
|
|
|
|
8 * unpack("V",substr($hdrl_data,$t+8,4)) |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
6
|
|
|
|
|
54
|
$last_tag = 0; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
} |
132
|
3
|
|
|
|
|
42
|
return 1; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
1; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |