summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSylvain Munaut2011-04-28 22:30:30 +0200
committerSylvain Munaut2011-04-28 22:30:30 +0200
commit1dd7c84733b20ba776510369e9daba1a822c5b44 (patch)
tree607b41ec6e8c0e295751789fcee0a507f7039128 /src
parentcore/conv: Add some generic code for convolutional coding/decoding (diff)
downloadlibosmocore-1dd7c84733b20ba776510369e9daba1a822c5b44.tar.gz
libosmocore-1dd7c84733b20ba776510369e9daba1a822c5b44.tar.xz
libosmocore-1dd7c84733b20ba776510369e9daba1a822c5b44.zip
core/conv: Only consider error for non-zero soft values
If the input value is '0' it should not really affect the error since it's just an indecisive bit. We accept this either an internal '0' (generated via puncture) or as an external '0' (generated via an external puncturing scheme). A real received bit should never be '0', it's always gonna be closer to 1 or the other value ... (thanks to mad@auth.se on the ML for the idea) Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r--src/conv.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/conv.c b/src/conv.c
index cf820a3..70bdffb 100644
--- a/src/conv.c
+++ b/src/conv.c
@@ -389,9 +389,12 @@ osmo_conv_decode_finish(struct osmo_conv_decoder *decoder,
m = 1 << (code->N - 1); /* mask for 'out' bit selection */
for (j=0; j<code->N; j++) {
- ov = (out & m) ? -127 : 127; /* sbit_t value for it */
- e = ((int)in_sym[j]) - ov; /* raw error for this bit */
- nae += (e * e) >> 9; /* acc the squared/scaled value */
+ int is = (int)in_sym[j];
+ if (is) {
+ ov = (out & m) ? -127 : 127; /* sbit_t value for it */
+ e = is - ov; /* raw error for this bit */
+ nae += (e * e) >> 9; /* acc the squared/scaled value */
+ }
m >>= 1; /* next mask bit */
}