summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/src/bitloading.c
diff options
context:
space:
mode:
authorJerome Jutteau2010-10-11 09:53:03 +0200
committerjutteau2010-12-09 16:56:51 +0100
commit16fe294f361f32ffb515f4239315773f7941546a (patch)
tree3f8a0dd2763dea66a11555ff15600f6fd600dfe0 /cesar/ce/rx/bitloading/src/bitloading.c
parentdfc0f32855b3d93d196a74731540d0106da186f6 (diff)
cesar/ce/rx/bl: compute new tone map using optimisation table, closes #1933
Diffstat (limited to 'cesar/ce/rx/bitloading/src/bitloading.c')
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index 683f5936a7..14708ebd5e 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -14,6 +14,7 @@
#include "ce_rx_bl_fsm_defs.h"
#include "ce/rx/bitloading/inc/ber.h"
#include "ce/rx/bitloading/inc/bitloading.h"
+#include "mac/common/tonemap.h"
#define LIB_HEAPSORT_USER_TYPE ce_rx_bl_ber_impact_t
#define LIB_HEAPSORT_USER_COMP_LESSER ce_rx_bl_ber_impact_compare
@@ -397,3 +398,121 @@ ce_rx_bl_tone_map_update_count (ce_rx_bl_tone_map_update_actions_t action,
/* Return value must be <= PHY_CARRIER_NB (max shift value). */
return (nb > PHY_CARRIER_NB ? PHY_CARRIER_NB : nb);
}
+
+ce_rx_bl_tone_map_update_status_t
+ce_rx_bl_tone_map_update_compute_new_tonemap (u64 ber_target,
+ u64 means
+ [CE_RX_BL_BER_SLIDING_MEAN_NB],
+ u16 *opti,
+ uint *opti_cursor,
+ tonemap_t *tm, uint tone_en,
+ tonemap_t **new_tonemap)
+{
+ /* New generated tone map. */
+ tonemap_t *new_tm = NULL;
+ uint new_opti_cursor = 0;
+ /* Number of tones to shift in the optimisation table. */
+ u16 shift_count = 0;
+ uint cpt = 0;
+ ce_rx_bl_tone_map_update_actions_t action = CE_RX_BL_TONE_MAP_UPDATE_NONE;
+ u32 *tone_word = NULL;
+ s8 mod = -1;
+ /* Output. */
+ ce_rx_bl_tone_map_update_status_t out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_OK;
+
+ /* Check parameters. */
+ dbg_assert (opti);
+ dbg_assert (opti_cursor);
+ dbg_assert (tm);
+ dbg_assert (new_tonemap);
+
+ /* Compute action and shift count. */
+ action = ce_rx_bl_tone_map_update_action (ber_target, means);
+ shift_count = ce_rx_bl_tone_map_update_count (action, ber_target, means);
+
+ /* Check optimisation table limits and action result. */
+ switch (action)
+ {
+ case CE_RX_BL_TONE_MAP_UPDATE_NONE:
+ return CE_RX_BL_TONE_MAP_UPDATE_STATUS_NOTHING;
+ break;
+ case CE_RX_BL_TONE_MAP_UPDATE_MINUS:
+ if (*opti_cursor == 0)
+ return CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MIN;
+ if ((int) (*opti_cursor - shift_count) < 0)
+ {
+ out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MIN;
+ new_opti_cursor = 0;
+ }
+ else
+ new_opti_cursor = *opti_cursor - shift_count;
+ break;
+ case CE_RX_BL_TONE_MAP_UPDATE_PLUS:
+ if (*opti_cursor >= tone_en)
+ return CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MAX;
+ if (*opti_cursor + shift_count >= tone_en)
+ {
+ out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_OUT_OF_RANGE_MAX;
+ new_opti_cursor = tone_en - 1;
+ }
+ else
+ new_opti_cursor = *opti_cursor + shift_count;
+ break;
+ default:
+ dbg_assert (action < CE_RX_BL_TONE_MAP_UPDATE_NB);
+ break;
+ }
+
+ /* Create a new tone map. */
+ new_tm = tonemap_alloc ();
+ dbg_assert (new_tm);
+
+ /* Copy current tone map to new tone map. */
+ tonemap_copy (new_tm, tm);
+
+ /*
+ * For each adjusted tones from the optimisation table,
+ * update new tone map.
+ */
+ if (action == CE_RX_BL_TONE_MAP_UPDATE_MINUS)
+ for (cpt = new_opti_cursor;
+ cpt < *opti_cursor;
+ cpt++)
+ {
+ tone_word = NULL;
+ mod = tonemap_get_tone (new_tm, opti[cpt], &tone_word);
+ dbg_assert (tone_word);
+
+ /* Decrease tone. */
+ dbg_check (tonemap_decrease_tone (new_tm, opti[cpt]));
+
+ /* Update bits per symbols. */
+ new_tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
+ new_tm->bits_per_symbol += CE_BIT_PER_MOD[mod - 1];
+ }
+ if (action == CE_RX_BL_TONE_MAP_UPDATE_PLUS)
+ /* We must start to boost at the cursor position and stop before new
+ * cursor position. */
+ for (cpt = *opti_cursor;
+ cpt != new_opti_cursor;
+ cpt++)
+ {
+ tone_word = NULL;
+ mod = tonemap_get_tone (new_tm, opti[cpt], &tone_word);
+ dbg_assert (tone_word);
+ /* Increase tone. */
+ if (!tonemap_increase_tone (new_tm, opti[cpt]))
+ {
+ out = CE_RX_BL_TONE_MAP_UPDATE_STATUS_MAX_CARRIAGE;
+ break;
+ }
+
+ /* Update bits per symbols. */
+ new_tm->bits_per_symbol -= CE_BIT_PER_MOD[mod];
+ new_tm->bits_per_symbol += CE_BIT_PER_MOD[mod + 1];
+ }
+
+ *new_tonemap = new_tm;
+ *opti_cursor = new_opti_cursor;
+ return out;
+}