| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Video::Delay::Func; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
|
4
|
5
|
|
|
5
|
|
113379
|
use strict; |
|
|
5
|
|
|
|
|
14
|
|
|
|
5
|
|
|
|
|
128
|
|
|
5
|
5
|
|
|
5
|
|
23
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
151
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# Modules. |
|
8
|
5
|
|
|
5
|
|
3795
|
use Class::Utils qw(set_params); |
|
|
5
|
|
|
|
|
113400
|
|
|
|
5
|
|
|
|
|
124
|
|
|
9
|
5
|
|
|
5
|
|
430
|
use English qw(-no_match_vars); |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
37
|
|
|
10
|
5
|
|
|
5
|
|
2300
|
use Error::Pure qw(err); |
|
|
5
|
|
|
|
|
9
|
|
|
|
5
|
|
|
|
|
1566
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Version. |
|
13
|
|
|
|
|
|
|
our $VERSION = 0.05; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Constructor. |
|
16
|
|
|
|
|
|
|
sub new { |
|
17
|
7
|
|
|
7
|
1
|
7693
|
my ($class, @params) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Create object. |
|
20
|
7
|
|
|
|
|
17
|
my $self = bless {}, $class; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Math function. |
|
23
|
|
|
|
|
|
|
$self->{'func'} = sub { |
|
24
|
1
|
|
|
1
|
|
2
|
my $t = shift; |
|
25
|
1
|
|
|
|
|
5
|
return 1000 * sin($t); |
|
26
|
7
|
|
|
|
|
35
|
}; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Counter increment. |
|
29
|
7
|
|
|
|
|
15
|
$self->{'incr'} = 0.1; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Process params. |
|
32
|
7
|
|
|
|
|
23
|
set_params($self, @params); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Counter. |
|
35
|
5
|
|
|
|
|
62
|
$self->{'counter'} = 0; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Check 'func' parameters. |
|
38
|
5
|
100
|
100
|
|
|
31
|
if (ref $self->{'func'} ne '' && ref $self->{'func'} ne 'CODE') { |
|
39
|
1
|
|
|
|
|
3
|
err "Parameter 'func' must be scalar or code."; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Object. |
|
43
|
4
|
|
|
|
|
11
|
return $self; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Get delay. |
|
47
|
|
|
|
|
|
|
sub delay { |
|
48
|
8
|
|
|
8
|
1
|
1701
|
my $self = shift; |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Counter. |
|
51
|
8
|
|
|
|
|
17
|
$self->{'counter'} += $self->{'incr'}; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Function string. |
|
54
|
8
|
|
|
|
|
11
|
my $ret; |
|
55
|
8
|
100
|
|
|
|
21
|
if (ref $self->{'func'} eq '') { |
|
56
|
4
|
|
|
|
|
5
|
my $input = $self->{'func'}; |
|
57
|
4
|
|
|
|
|
6
|
my $c = $self->{'counter'}; |
|
58
|
4
|
|
|
|
|
12
|
$input =~ s/t/$c/g; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Eval. |
|
61
|
4
|
|
|
|
|
151
|
$ret = eval $input; |
|
62
|
4
|
100
|
|
|
|
17
|
if ($EVAL_ERROR) { |
|
63
|
1
|
|
|
|
|
7
|
err 'Error in function.', |
|
64
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Callback. |
|
68
|
|
|
|
|
|
|
} else { |
|
69
|
4
|
|
|
|
|
11
|
$ret = $self->{'func'}->($self->{'counter'}); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
7
|
|
|
|
|
21
|
return $ret; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__ |