line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OnlineCode::Encoder; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24002
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
94
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
551
|
use Net::OnlineCode; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS $VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
224
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Inherit from base class |
15
|
|
|
|
|
|
|
@ISA = qw(Net::OnlineCode Exporter); |
16
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$VERSION = '0.02'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my %opts = ( |
25
|
|
|
|
|
|
|
# include any encoder-specific arguments here |
26
|
|
|
|
|
|
|
initial_rng => undef, |
27
|
|
|
|
|
|
|
@_ |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
print "encoder mblocks: $self->{mblocks}\n"; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
croak "Failed to create superclass\n" unless ref($self); |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->auxiliary_mapping($opts{initial_rng}); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# delete unwanted mblocks elements from aux_mapping |
39
|
|
|
|
|
|
|
#splice $self->{aux_mapping}, 0, $self->{mblocks}; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# to create check blocks, call the parent's checkblock_mapping method |
46
|
|
|
|
|
|
|
# to find the mapping, then optionally expand any auxiliary block |
47
|
|
|
|
|
|
|
# numbers with the message blocks they're composed of. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub create_check_block { |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
1
|
|
my ($self, $rng) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# already tested by parent method: |
54
|
|
|
|
|
|
|
# croak "rng parameter must be an object ref" unless ref($rng); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $xor_list = $self->checkblock_mapping($rng); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Optionally replace auxiliary indices with a list of message |
59
|
|
|
|
|
|
|
# indices. Message blocks may appear multiple times in the |
60
|
|
|
|
|
|
|
# expansion: once for an explicit mention in the checkblock, and |
61
|
|
|
|
|
|
|
# potentially several times in the expansion of auxiliary blocks. We |
62
|
|
|
|
|
|
|
# eliminate any message blocks that appear an even number of times |
63
|
|
|
|
|
|
|
# in the expansion since xoring by the same thing twice is a null |
64
|
|
|
|
|
|
|
# operation. |
65
|
|
|
|
|
|
|
# |
66
|
|
|
|
|
|
|
# Note that although we use the same option name (expand_aux) in the |
67
|
|
|
|
|
|
|
# encoder and decoder, the implementations are different. Here we |
68
|
|
|
|
|
|
|
# expand aux blocks indices into message indexes, whereas in the |
69
|
|
|
|
|
|
|
# decoder, we expand them into check block indices. |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ($self->{expand_aux}) { |
72
|
0
|
|
|
|
|
|
return [ $self->blklist_to_msglist(@$xor_list) ]; |
73
|
|
|
|
|
|
|
} else { |
74
|
0
|
|
|
|
|
|
return $xor_list; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |