1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* -*- c++ -*- */
/*
* Copyright 2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
* SPDX-License-Identifier: GPL-3.0-or-later
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/fec/polar_encoder_systematic.h>
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
namespace gr {
namespace fec {
namespace code {
generic_encoder::sptr polar_encoder_systematic::make(
int block_size, int num_info_bits, std::vector<int> frozen_bit_positions)
{
return generic_encoder::sptr(
new polar_encoder_systematic(block_size, num_info_bits, frozen_bit_positions));
}
polar_encoder_systematic::polar_encoder_systematic(int block_size,
int num_info_bits,
std::vector<int> frozen_bit_positions)
: polar_common(block_size, num_info_bits, frozen_bit_positions, std::vector<char>())
{
d_volk_syst_intermediate = (unsigned char*)volk_malloc(
sizeof(unsigned char) * block_size, volk_get_alignment());
}
polar_encoder_systematic::~polar_encoder_systematic()
{
volk_free(d_volk_syst_intermediate);
}
void polar_encoder_systematic::generic_work(void* in_buffer, void* out_buffer)
{
const unsigned char* in = (const unsigned char*)in_buffer;
unsigned char* out = (unsigned char*)out_buffer;
volk_encode(out, in);
bit_reverse_and_reset_frozen_bits(d_volk_syst_intermediate, out);
volk_encode_block(out, d_volk_syst_intermediate);
}
void polar_encoder_systematic::bit_reverse_and_reset_frozen_bits(
unsigned char* outbuf, const unsigned char* inbuf)
{
memset(outbuf, 0, sizeof(unsigned char) * block_size());
for (int i = 0; i < num_info_bits(); i++) {
outbuf[d_info_bit_positions[i]] = inbuf[d_info_bit_positions_reversed[i]];
}
}
} /* namespace code */
} /* namespace fec */
} /* namespace gr */
|