MCPcopy Create free account
hub / github.com/aff3ct/aff3ct / _encode

Method _encode

src/Module/Encoder/Conv/Encoder_conv.cpp:125–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124template<typename B>
125void
126Encoder_conv<B>::_encode(const B* U_K, B* X_N, const size_t /*frame_id*/)
127{
128 int state = 0;
129
130 // Encode K information bits
131 for (int i = 0; i < this->K; i++)
132 {
133 int b = static_cast<int>(U_K[i]);
134 int packed = output_table[2 * state + b];
135 state = next_state_table[2 * state + b];
136
137 // Unpack n_poly output bits into interleaved positions
138 for (int p = 0; p < n_poly; p++)
139 X_N[i * n_poly + p] = static_cast<B>((packed >> (n_poly - 1 - p)) & 1);
140 }
141
142 // Tail bits: drive state back to 0 by feeding 0
143 for (int i = 0; i < n_ff; i++)
144 {
145 int b = 0;
146 int packed = output_table[2 * state + b];
147 state = next_state_table[2 * state + b];
148
149 for (int p = 0; p < n_poly; p++)
150 X_N[(this->K + i) * n_poly + p] = static_cast<B>((packed >> (n_poly - 1 - p)) & 1);
151 }
152
153 if (state != 0)
154 {
155 std::stringstream message;
156 message << "'state' should be equal to 0 after tail bits ('state' = " << state << ").";
157 throw spu::tools::runtime_error(__FILE__, __LINE__, __func__, message.str());
158 }
159}
160
161template<typename B>
162std::vector<std::vector<int>>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected