diff --git a/src/UpperPHY/LDPC/arm_ldpc_rate_matching.cpp b/src/UpperPHY/LDPC/arm_ldpc_rate_matching.cpp index 8efac64..c9cb8c4 100644 --- a/src/UpperPHY/LDPC/arm_ldpc_rate_matching.cpp +++ b/src/UpperPHY/LDPC/arm_ldpc_rate_matching.cpp @@ -59,6 +59,17 @@ void bit_selection(uint32_t z, uint32_t n, uint32_t e, uint32_t len_filler_bits, } in_bits = scratch_buf1; + + // k0 is an index within the encoder output with filler bits + // but in_bits is now without filler bits + // so there is an offset to take into account depending on + // whether k0 falls before, within or after the filler bits + if(k0 > len_s_f_bits) { + k0 = k0 - len_filler_bits; + } else if(k0 > len_s_bits && k0 <= len_s_f_bits) { + k0 = len_s_bits; + } + } // k0 depends on the redundancy version id.