diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2011-11-24 17:47:32 +0100 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2011-11-24 17:47:32 +0100 |
commit | ae8dbb4d776461c8945570594d67d8bb9b7100c5 (patch) | |
tree | c378612cf0551513d5f7f2d2cf875858d76d5344 /src | |
parent | 297d13f4604c330efac19c03c12d590730076ed5 (diff) |
core/conv: Add utility methods to know length of coded/decoded vectors
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/conv.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -42,6 +42,40 @@ /* ------------------------------------------------------------------------ */ +/* Common */ +/* ------------------------------------------------------------------------ */ + +int +osmo_conv_get_input_length(const struct osmo_conv_code *code, int len) +{ + return len <= 0 ? code->len : len; +} + +int +osmo_conv_get_output_length(const struct osmo_conv_code *code, int len) +{ + int pbits, in_len, out_len; + + /* Input length */ + in_len = osmo_conv_get_input_length(code, len); + + /* Output length */ + out_len = in_len * code->N; + + if (code->term == CONV_TERM_FLUSH) + out_len += code->N * (code->K - 1); + + /* Count punctured bits */ + if (code->puncture) { + for (pbits=0; code->puncture[pbits] >= 0; pbits++); + out_len -= pbits; + } + + return out_len; +} + + +/* ------------------------------------------------------------------------ */ /* Encoding */ /* ------------------------------------------------------------------------ */ |