summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/src/transition.c
diff options
context:
space:
mode:
authorYacine Belkadi2011-12-14 08:51:32 +0100
committerYacine Belkadi2012-01-12 10:22:31 +0100
commit7ed7f5d2760322b8b33d75760b396d951c953690 (patch)
tree9f97b45d9206cbbc8903d9bb358768d24accdacf /cesar/ce/rx/bitloading/src/transition.c
parent5f385c4405df65c89077a1af56e5c02420bf2386 (diff)
cesar/ce/rx/bl: refactor, refs #2755
Diffstat (limited to 'cesar/ce/rx/bitloading/src/transition.c')
-rw-r--r--cesar/ce/rx/bitloading/src/transition.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/cesar/ce/rx/bitloading/src/transition.c b/cesar/ce/rx/bitloading/src/transition.c
index e47c9cad20..1a2edb3ba5 100644
--- a/cesar/ce/rx/bitloading/src/transition.c
+++ b/cesar/ce/rx/bitloading/src/transition.c
@@ -294,18 +294,22 @@ ce_rx_bl_fsm__TRACKING__data (ce_rx_t *ce_rx,
sta->rx_tonemaps->sound_frame_counter = TONEMAP_SOUND_FRAME_COUNTER;
+ bool tm_is_negotiated =
+ TONEMAP_INDEX_IS_NEGOTIATED (measure->rx_params.tmi_av);
+
+ tonemap_t *tm;
+ if (tm_is_negotiated)
+ {
+ tm = sta->rx_tonemaps->tm[measure->rx_params.tmi_av];
+ }
+
/* Increase CE statistics. */
/* If measure is a negotiated tone map. */
- if (TONEMAP_INDEX_IS_NEGOTIATED (measure->rx_params.tmi_av))
+ if (tm_is_negotiated && tm)
{
- /* Get tone map. */
- tonemap_t *tm = sta->rx_tonemaps->tm[measure->rx_params.tmi_av];
- if (tm)
- {
- /* Update statistics. */
- tm->nb_frame++;
- tm->nb_pb += measure->total_pb_count;
- }
+ /* Update statistics. */
+ tm->nb_frame++;
+ tm->nb_pb += measure->total_pb_count;
}
/* Measure should only be processed if the TMI used is the one we are
@@ -315,14 +319,15 @@ ce_rx_bl_fsm__TRACKING__data (ce_rx_t *ce_rx,
{
ce_rx_bitloading_t *bl = &sta->ce_rx_bt;
dbg_assert (bl);
+
+ u8 good_pb_count = measure->total_pb_count - measure->false_pb_count;
+ u16 pb_size =
+ (measure->rx_params.pb_size == PHY_PB_SIZE_136 ? 136 : 520) * 8;
/* Update BER sliding means. */
- if (measure->total_pb_count != measure->false_pb_count)
+ if (good_pb_count)
ce_rx_bl_ber_sliding_mean_update
(bl, ce_rx_bl_ber_quantify
- (measure->ber_sum,
- measure->total_pb_count - measure->false_pb_count,
- (measure->rx_params.pb_size == PHY_PB_SIZE_136 ? 136 : 520)
- * 8));
+ (measure->ber_sum, good_pb_count, pb_size));
/* Update PB Error Rate sliding mean. */
ce_rx_bl_pber_sliding_mean_update (bl,
@@ -338,7 +343,7 @@ ce_rx_bl_fsm__TRACKING__data (ce_rx_t *ce_rx,
bl->stats.curr_pberr_rate_mean = sta->ce_rx_bt.pber_sliding_mean;
/* High PB Error rate (not on small frame)? */
- if (TONEMAP_INDEX_IS_NEGOTIATED (measure->rx_params.tmi_av)
+ if (tm_is_negotiated
&& (measure->total_pb_count >= ce_rx_bl_min_pb_per_frame_)
&& (ce_rx_bl_pb_total_factor_ * measure->false_pb_count
> ce_rx_bl_pb_false_factor_ * measure->total_pb_count))
@@ -376,13 +381,10 @@ ce_rx_bl_fsm__TRACKING__data (ce_rx_t *ce_rx,
{
/* Reset frame counter. */
bl->high_pb_error_rate_frame_counter = 0;
- /* Get tone map. */
- tonemap_t *tm
- = sta->rx_tonemaps->tm[measure->rx_params.tmi_av];
/* If this is not negotiated tone map (ROBO)
or the tone map is not at the maximum
and not too soon. */
- if ((!TONEMAP_INDEX_IS_NEGOTIATED (measure->rx_params.tmi_av)
+ if ((!tm_is_negotiated
||
((tm)
&& (tm->bits_per_symbol
@@ -394,8 +396,7 @@ ce_rx_bl_fsm__TRACKING__data (ce_rx_t *ce_rx,
{
/* Compute lower bound. */
u64 ber_target;
- if (!TONEMAP_INDEX_IS_NEGOTIATED
- (measure->rx_params.tmi_av))
+ if (!tm_is_negotiated)
{
ber_target = ce_rx_bl_ber_pt_robo
(ce_rx->mac_config->tonemask_info.carrier_nb);