summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/test
diff options
context:
space:
mode:
authorCyril Jourdan2013-04-18 16:09:35 +0200
committerCyril Jourdan2013-04-18 16:42:08 +0200
commit7c20f872a76ae8d6fe10223528287d427cf87076 (patch)
treee07671a1e7f332fdbb27a9fad1e6fbadda242302 /cesar/ce/rx/bitloading/test
parent13e0d70d0f2870c395f845ebdfadb0452c860bf9 (diff)
cesar/ce/rx/bl: update default tonemap when restarting an interval, refs #2588
The idea is to keep the default tonemap when we have only one interval active that is restarting, if it is doing so to make it better. If the update function seems a bit complex, it is because it is ready to be modified to handle the case where there is more than one interval (see #3880).
Diffstat (limited to 'cesar/ce/rx/bitloading/test')
-rw-r--r--cesar/ce/rx/bitloading/test/intervals/src/test_intervals_fsm.c7
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_intervals.c125
2 files changed, 129 insertions, 3 deletions
diff --git a/cesar/ce/rx/bitloading/test/intervals/src/test_intervals_fsm.c b/cesar/ce/rx/bitloading/test/intervals/src/test_intervals_fsm.c
index 2592f83200..dd40bba3ae 100644
--- a/cesar/ce/rx/bitloading/test/intervals/src/test_intervals_fsm.c
+++ b/cesar/ce/rx/bitloading/test/intervals/src/test_intervals_fsm.c
@@ -71,14 +71,15 @@ test_ce_rx_bl_fsm_INTERVAL_TRACKING (test_t t)
measure.rx_params.sound_complete = false;
sta_t sta;
- sta.intervals = ce_rx_bl_intervals_alloc (tested_tmi);
+ sta.intervals = ce_rx_bl_intervals_alloc (tested_tmi + 1);
tonemaps_t rx_tms, tx_tms;
sta.rx_tonemaps = &rx_tms;
+ sta.rx_tonemaps->default_tmi = tested_tmi + 1;
sta.tx_tonemaps = &tx_tms;
/* The tmi of the intervals is different from the default tmi. */
- sta.rx_tonemaps->default_tmi = tested_tmi + 1;
+ sta.intervals->tmi[tested_fsm_id] = tested_tmi;
test_case_begin (t, "INTERVAL_TRACKING, interval_sound appears");
@@ -109,7 +110,7 @@ test_ce_rx_bl_fsm_INTERVAL_TRACKING (test_t t)
.tmi = TONEMAP_INDEX_INTERVAL_UNAVAILABLE);
else
fsm_base[pos++] = (scenario_entry_t) SCENARIO_EVENT (
- mac_interval_append, .tms = &rx_tms, .tmi = tested_tmi);
+ mac_interval_append, .tms = &rx_tms, .tmi = tested_tmi + 1);
}
fsm_base[pos++] = (scenario_entry_t) SCENARIO_EVENT (
mac_interval_commit_changes, .tms = &rx_tms);
diff --git a/cesar/ce/rx/bitloading/test/src/test_intervals.c b/cesar/ce/rx/bitloading/test/src/test_intervals.c
index d831d5b4b9..13d7196c12 100644
--- a/cesar/ce/rx/bitloading/test/src/test_intervals.c
+++ b/cesar/ce/rx/bitloading/test/src/test_intervals.c
@@ -552,6 +552,129 @@ test_suite_ce_rx_bl_intervals_update_tmi (test_t t)
}
void
+test_suite_ce_rx_bl_intervals_update_default_tm (test_t t)
+{
+ test_case_begin (t, "Update global default tonemap.");
+
+ uint old_fsm_nb = mac_interval_fsm_count_;
+ uint old_repetition_nb = mac_interval_repetition_count_;
+
+ sta_t sta;
+ tonemap_t tm;
+ int i;
+
+ sta.rx_tonemaps = tonemaps_alloc ();
+ sta.rx_tonemaps->tm[4] = &tm;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
+ /* This tests only works if the number of intervals is known, so I prefer
+ * to manage this locally. */
+ /* Start with one interval. */
+ mac_interval_fsm_count_ = 1;
+ mac_interval_repetition_count_ = 1;
+
+ sta.intervals = ce_rx_bl_intervals_alloc (4);
+
+ test_begin (t, "One interval, not restarting.")
+ {
+ sta.rx_tonemaps->default_tmi = 0;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 4);
+
+ sta.rx_tonemaps->default_tmi = 4;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 4);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released != 0);
+
+ sta.intervals->tmi[0] = 5;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 5);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+ } test_end;
+
+ sta.rx_tonemaps->default_tmi = 4;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
+ test_begin (t, "One interval, restarting for a better tonemap.")
+ {
+ sta.intervals->tmi[0] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
+ sta.intervals->intervals[0]->default_robo = false;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 4);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released != 0);
+ } test_end;
+ test_begin (t, "One interval, restarting for a worst tonemap.")
+ {
+ sta.intervals->intervals[0]->default_robo = true;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 0);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+ } test_end;
+
+ /* Clean. */
+ sta.rx_tonemaps->tm[4]->released = 0;
+ ce_rx_bl_intervals_free (sta.intervals);
+
+ /* Now, test with several intervals. */
+ mac_interval_fsm_count_ = 6;
+ mac_interval_repetition_count_ = 4;
+
+ sta.intervals = ce_rx_bl_intervals_alloc (4);
+
+ test_begin (t, "Several intervals, no one restarting.")
+ {
+ sta.rx_tonemaps->default_tmi = 0;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 4);
+
+ sta.rx_tonemaps->default_tmi = 4;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 4);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released != 0);
+
+ for (i = 0; i < mac_interval_fsm_count_; i++)
+ sta.intervals->tmi[i] = 5;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 5);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+
+ /* TODO: add cases of new tonemap calculation (see #3880). */
+ } test_end;
+
+ sta.rx_tonemaps->default_tmi = 4;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
+ test_begin (t, "Several intervals, one restarting for a better tonemap.")
+ {
+ /* TODO: This will change with new tonemap calculation (see #3880). */
+ sta.intervals->tmi[0] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
+ sta.intervals->intervals[0]->default_robo = false;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 4);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released != 0);
+ } test_end;
+ test_begin (t, "Several intervals, one restarting for a worst tonemap.")
+ {
+ sta.intervals->tmi[1] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
+ sta.intervals->intervals[1]->default_robo = true;
+ ce_rx_bl_intervals_update_default_tm (&sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 0);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+ } test_end;
+
+ /* Clean. */
+ sta.rx_tonemaps->tm[4] = NULL;
+ tonemaps_release (sta.rx_tonemaps);
+ ce_rx_bl_intervals_free (sta.intervals);
+ mac_interval_fsm_count_ = old_fsm_nb;
+ mac_interval_repetition_count_ = old_repetition_nb;
+}
+
+void
test_suite_ce_rx_bl_intervals (test_t t)
{
/* Intervals init and uninit. */
@@ -566,6 +689,8 @@ test_suite_ce_rx_bl_intervals (test_t t)
test_suite_ce_rx_bl_intervals_measure_to_event (t);
/* Updating TMI of intervals. */
test_suite_ce_rx_bl_intervals_update_tmi (t);
+ /* Updating global default tonemap. */
+ test_suite_ce_rx_bl_intervals_update_default_tm (t);
}
int