| 160 | |
| 161 | template<typename B> |
| 162 | std::vector<std::vector<int>> |
| 163 | Encoder_conv<B>::get_trellis() |
| 164 | { |
| 165 | std::vector<std::vector<int>> trellis(10, std::vector<int>(n_states)); |
| 166 | |
| 167 | // Fill trellis[0..5] for BCJR compatibility (same convention as RSC encoder) |
| 168 | std::vector<bool> occurrence(n_states, false); |
| 169 | |
| 170 | for (int i = 0; i < n_states; i++) |
| 171 | { |
| 172 | // input = 0 |
| 173 | int next0 = next_state_table[2 * i + 0]; |
| 174 | int out0 = output_table[2 * i + 0]; |
| 175 | |
| 176 | trellis[0 + (occurrence[next0] ? 3 : 0)][next0] = i; // initial state |
| 177 | trellis[1 + (occurrence[next0] ? 3 : 0)][next0] = +1; // gamma coeff |
| 178 | trellis[2 + (occurrence[next0] ? 3 : 0)][next0] = out0; // gamma (packed output) |
| 179 | |
| 180 | trellis[6][i] = next0; // next state, input = 0 |
| 181 | trellis[7][i] = out0; // packed output, input = 0 |
| 182 | |
| 183 | occurrence[next0] = true; |
| 184 | |
| 185 | // input = 1 |
| 186 | int next1 = next_state_table[2 * i + 1]; |
| 187 | int out1 = output_table[2 * i + 1]; |
| 188 | |
| 189 | trellis[0 + (occurrence[next1] ? 3 : 0)][next1] = i; // initial state |
| 190 | trellis[1 + (occurrence[next1] ? 3 : 0)][next1] = -1; // gamma coeff |
| 191 | trellis[2 + (occurrence[next1] ? 3 : 0)][next1] = out1; // gamma (packed output) |
| 192 | |
| 193 | trellis[8][i] = next1; // next state, input = 1 |
| 194 | trellis[9][i] = out1; // packed output, input = 1 |
| 195 | |
| 196 | occurrence[next1] = true; |
| 197 | } |
| 198 | |
| 199 | return trellis; |
| 200 | } |
| 201 | |
| 202 | // ==================================================================================== explicit template instantiation |
| 203 | #include "Tools/types.h" |
no outgoing calls
no test coverage detected