summaryrefslogtreecommitdiff
path: root/cesar/ce/rx
diff options
context:
space:
mode:
authordufour2009-07-16 09:13:11 +0000
committerdufour2009-07-16 09:13:11 +0000
commitc6f31e2719d60dba8a68ea24d64d702a5ff7c9ed (patch)
treed5a24fd231704d77caf50d26c7d06badaf1d5830 /cesar/ce/rx
parent57552517f2b2b5257c1c7ec270db764fc0ac5187 (diff)
* ce/rx:
- add a function to generate the value of the counter encoded in RLE, - fix RLE encoding (modulation first and RLE counter after). - add some tests for the generation of the CM_CHAN_EST.IND MME. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4974 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce/rx')
-rw-r--r--cesar/ce/rx/cp/inc/mme.h14
-rw-r--r--cesar/ce/rx/cp/src/mme.c37
-rw-r--r--cesar/ce/rx/cp/test/src/test_mme.c160
3 files changed, 189 insertions, 22 deletions
diff --git a/cesar/ce/rx/cp/inc/mme.h b/cesar/ce/rx/cp/inc/mme.h
index 94801d6d46..e9ecc515f4 100644
--- a/cesar/ce/rx/cp/inc/mme.h
+++ b/cesar/ce/rx/cp/inc/mme.h
@@ -21,6 +21,20 @@
BEGIN_DECLS
/**
+ * Generate a count encoded in RLE.
+ * \param count counter of same successive tones.
+ * \return the counter encoded in RLE.
+ */
+extern inline u8
+ce_rx_cp_mme_get_rle (u8 count)
+{
+ dbg_assert (count >= 3 && count <= 74);
+ return (((count - 3) / 8 + 7) << 4)
+ + (8 + (count - 3) % 8);
+}
+
+
+/**
* Compute the size of a tone map using the RLE encoding.
* \param tm the tone map to compute size.
* \param tonemask the tone mask.
diff --git a/cesar/ce/rx/cp/src/mme.c b/cesar/ce/rx/cp/src/mme.c
index da960049d3..e201a7bdf6 100644
--- a/cesar/ce/rx/cp/src/mme.c
+++ b/cesar/ce/rx/cp/src/mme.c
@@ -395,7 +395,7 @@ ce_rx_mme_send_cm_chan_est_ind (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms,
/* Write modulation required times. */
uint k;
for (k = 0; k < count; k++)
- bitstream_write (&mme->bitstream, modulation,
+ bitstream_write (&mme->bitstream, prev_modulation,
4);
/* Update CBD Length. */
cbd_length += count;
@@ -404,14 +404,15 @@ ce_rx_mme_send_cm_chan_est_ind (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms,
{
/* Sanity check. */
dbg_assert (count <= 74);
- /* Write one or two nibbles. */
- bitstream_write (&mme->bitstream, count,
- count < 11 ? 4 : 8);
/* Write modulation. */
- bitstream_write (&mme->bitstream, modulation,
+ bitstream_write (&mme->bitstream, prev_modulation,
4);
+ /* Write one or two nibbles. */
+ bitstream_write (&mme->bitstream,
+ ce_rx_cp_mme_get_rle (count),
+ count < 11 ? 4 : 8);
/* Update CBD Length. */
- cbd_length += 1 + count < 11 ? 1 : 2;
+ cbd_length += 1 + ((count < 11) ? 1 : 2);
}
/* Reset counter. */
count = 1;
@@ -452,7 +453,7 @@ ce_rx_mme_send_cm_chan_est_ind (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms,
/* Write modulation required times. */
uint k;
for (k = 0; k < count; k++)
- bitstream_write (&mme->bitstream, modulation,
+ bitstream_write (&mme->bitstream, prev_modulation,
4);
/* Update CBD Length. */
cbd_length += count;
@@ -461,14 +462,15 @@ ce_rx_mme_send_cm_chan_est_ind (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms,
{
/* Sanity check. */
dbg_assert (count <= 74);
- /* Write one or two nibbles. */
- bitstream_write (&mme->bitstream, count,
- count < 11 ? 4 : 8);
/* Write modulation. */
- bitstream_write (&mme->bitstream, modulation,
+ bitstream_write (&mme->bitstream, prev_modulation,
4);
+ /* Write one or two nibbles. */
+ bitstream_write (&mme->bitstream,
+ ce_rx_cp_mme_get_rle (count),
+ count < 11 ? 4 : 8);
/* Update CBD Length. */
- cbd_length += 1 + count < 11 ? 1 : 2;
+ cbd_length += 1 + ((count < 11) ? 1 : 2);
}
/* Reset counter. */
count = 1;
@@ -500,14 +502,15 @@ ce_rx_mme_send_cm_chan_est_ind (cp_t *ctx, cp_sta_t *sta, tonemaps_t *tms,
{
/* Sanity check. */
dbg_assert (count <= 74);
- /* Write one or two nibbles. */
- bitstream_write (&mme->bitstream, count,
- count < 11 ? 4 : 8);
/* Write modulation. */
- bitstream_write (&mme->bitstream, modulation,
+ bitstream_write (&mme->bitstream, prev_modulation,
4);
+ /* Write one or two nibbles. */
+ bitstream_write (&mme->bitstream,
+ ce_rx_cp_mme_get_rle (count),
+ count < 11 ? 4 : 8);
/* Update CBD Length. */
- cbd_length += 1 + count < 11 ? 1 : 2;
+ cbd_length += 1 + ((count < 11) ? 1 : 2);
}
/* Write CBD length. */
bitstream_direct_write (mme->p_mme, cbd_len_pos, cbd_length, 16);
diff --git a/cesar/ce/rx/cp/test/src/test_mme.c b/cesar/ce/rx/cp/test/src/test_mme.c
index 66f58d6443..17a132108d 100644
--- a/cesar/ce/rx/cp/test/src/test_mme.c
+++ b/cesar/ce/rx/cp/test/src/test_mme.c
@@ -17,6 +17,9 @@
#include "ce/rx/cp/inc/mme.h"
#include "ce/common/ce.h"
+/**
+ * Generate header of MME CM_CHAN_EST.IND.
+ */
uint
mme_test_generate_header_cm_chan_est_ind (cp_t *cp, tonemaps_t *tms,
u8 initial_ce, u8 default_tmi,
@@ -47,18 +50,16 @@ mme_test_generate_header_cm_chan_est_ind (cp_t *cp, tonemaps_t *tms,
count++;
bitstream_write (bt, tms->scl_cfp ? 1 : 0, 8);
count++;
- bitstream_write (bt, tms->scl_cfp ? 1 : 0, 8);
- count++;
u8 tmi_count = 0;
uint i;
- for (i = 0; i < TONEMAP_INDEX_NB ; i++)
+ for (i = NEGOCIATED_TONEMAP_INDEX_FIRST; i < TONEMAP_INDEX_NB ; i++)
{
if (tmi_list & (1 << i))
tmi_count++;
}
bitstream_write (bt, tmi_count, 8);
count++;
- for (i = 0; i < TONEMAP_INDEX_NB ; i++)
+ for (i = NEGOCIATED_TONEMAP_INDEX_FIRST; i < TONEMAP_INDEX_NB ; i++)
if (tmi_list & (1 << i))
{
bitstream_write (bt, i, 8);
@@ -86,6 +87,31 @@ mme_test_generate_header_cm_chan_est_ind (cp_t *cp, tonemaps_t *tms,
return count;
}
+/**
+ * If there is a tone map, add the header of the tone map to the
+ * CM_CHAN_EST.IND MME.
+ */
+uint
+mme_test_generate_before_tm_cm_chan_est_ind (cp_t *cp, tonemap_t *tm)
+{
+ uint count = 0;
+ dbg_assert (cp);
+ dbg_assert (tm);
+ bitstream_t *bt = cp->vect_bt;
+ bitstream_write (bt, tm->cpf ? 1 : 0, 8);
+ count++;
+ bitstream_write (bt, tm->fecrate, 8);
+ count++;
+ bitstream_write (bt, tm->gil, 8);
+ count++;
+ bitstream_write (bt, 1, 8);
+ count++;
+ return count;
+}
+
+/**
+ * Finalize the CM_CHAN_EST.IND MME.
+ */
void
mme_test_generate_end_cm_chan_est_ind (cp_t *cp)
{
@@ -102,6 +128,25 @@ mme_test_suite (test_t t)
tonemask_default (ts.tonemask);
ts.carrier_nb = tonemask_carrier_nb (ts.tonemask);
+ test_suite_begin (t, "CE:RX:CP: RLE encoding");
+
+ test_begin (t, "RLE counter generation")
+ {
+ test_fail_if (ce_rx_cp_mme_get_rle (3) != 0x8);
+ test_fail_if (ce_rx_cp_mme_get_rle (4) != 0x9);
+ test_fail_if (ce_rx_cp_mme_get_rle (5) != 0xA);
+ test_fail_if (ce_rx_cp_mme_get_rle (6) != 0xB);
+ test_fail_if (ce_rx_cp_mme_get_rle (7) != 0xC);
+ test_fail_if (ce_rx_cp_mme_get_rle (8) != 0xD);
+ test_fail_if (ce_rx_cp_mme_get_rle (9) != 0xE);
+ test_fail_if (ce_rx_cp_mme_get_rle (10) != 0xF);
+ test_fail_if (ce_rx_cp_mme_get_rle (11) != 0x88);
+ test_fail_if (ce_rx_cp_mme_get_rle (12) != 0x89);
+ test_fail_if (ce_rx_cp_mme_get_rle (13) != 0x8A);
+ test_fail_if (ce_rx_cp_mme_get_rle (73) != 0xFE);
+ test_fail_if (ce_rx_cp_mme_get_rle (74) != 0xFF);
+ } test_end;
+
test_suite_begin (t, "CE:RX:CP:MME length computation");
test_begin (t, "tone map with all modulations set to the same value")
@@ -182,8 +227,113 @@ mme_test_suite (test_t t)
int_list.intervals_nb = 0;
ce_rx_mme_send_cm_chan_est_ind (&cp, &sta, tms, false, 0, 1, 0,
&int_list);
- tonemaps_release (tms);
} test_end;
+
+ test_begin (t, "CM_CHAN_EST.IND: refresh TMI list: not empty list")
+ {
+ /* No interval. */
+ tonemap_intervals_t int_list;
+ int_list.intervals_nb = 0;
+ u32 tmi_list = (1 << 5) | (1 << 1);
+ u8 default_tmi = 5;
+ cp.vect_size = mme_test_generate_header_cm_chan_est_ind
+ (&cp, tms, 1, default_tmi, tmi_list, &int_list,
+ 0);
+ mme_test_generate_end_cm_chan_est_ind (&cp);
+ ce_rx_mme_send_cm_chan_est_ind
+ (&cp, &sta, tms, false, 0, default_tmi, tmi_list, &int_list);
+ } test_end;
+
+ test_begin (t, "CM_CHAN_EST.IND: refresh TMI list: with intervals")
+ {
+ tonemap_intervals_t int_list;
+ int_list.intervals_nb = 2;
+ int_list.interval[0].end_offset_atu = 2;
+ int_list.interval[0].tmi = 5;
+ int_list.interval[1].end_offset_atu = 0xFFFF;
+ int_list.interval[0].tmi = 1;
+ u32 tmi_list = (1 << 5) | (1 << 1);
+ u8 default_tmi = 5;
+ cp.vect_size = mme_test_generate_header_cm_chan_est_ind
+ (&cp, tms, 1, default_tmi, tmi_list, &int_list,
+ 0);
+ mme_test_generate_end_cm_chan_est_ind (&cp);
+ ce_rx_mme_send_cm_chan_est_ind
+ (&cp, &sta, tms, false, 0, default_tmi, tmi_list, &int_list);
+ } test_end;
+
+ test_begin (t, "CM_CHAN_EST.IND: new tone map: same tones (0)")
+ {
+ uint i;
+ tonemap_intervals_t int_list;
+ int_list.intervals_nb = 2;
+ int_list.interval[0].end_offset_atu = 2;
+ int_list.interval[0].tmi = 5;
+ int_list.interval[1].end_offset_atu = 0xFFFF;
+ int_list.interval[0].tmi = 1;
+ u32 tmi_list = (1 << 5) | (1 << 1);
+ u8 default_tmi = 5;
+ tonemap_t *tm = tonemap_alloc ();
+ tms->tm[5] = tm;
+ /* Set all tones to 0. */
+ u8 *cur = tm->tmdma_desc_head->data;
+ for (i = 0; i < PHY_CARRIER_NB / 2; i++)
+ {
+ if (i == BLK_SIZE)
+ cur = tm->tmdma_desc_head->next->data;
+ *cur = 0;
+ cur++;
+ }
+ if (PHY_CARRIER_NB % 2)
+ *cur = 0;
+
+ /* Generate test vector. */
+ cp.vect_size = mme_test_generate_header_cm_chan_est_ind
+ (&cp, tms, 1, default_tmi, tmi_list, &int_list,
+ 5);
+ cp.vect_size += mme_test_generate_before_tm_cm_chan_est_ind (&cp, tm);
+ bitstream_t *bt = cp.vect_bt;
+ uint cbd_pos = bitstream_written_bits (bt);
+ bitstream_write (bt, 0, 16);
+ uint count = 0;
+ for (i = 0; i < (ts.carrier_nb / 74); i++)
+ {
+ bitstream_write (bt, 0, 4);
+ count += 4;
+ bitstream_write (bt, 0xFF, 8);
+ count += 8;
+ }
+ u8 remain = ts.carrier_nb % 74;
+ if (remain)
+ {
+ if (remain < 3)
+ for (i = 0; i < remain; i++)
+ {
+ bitstream_write (bt, 0, 4);
+ count += 4;
+ }
+ else
+ {
+ bitstream_write (bt, 0, 4);
+ count += 4;
+ u8 rle = ce_rx_cp_mme_get_rle (remain);
+ bitstream_write (bt, rle, rle > 0xF ? 8 : 4);
+ count += rle > 0xF ? 8 : 4;
+ }
+ }
+ bitstream_direct_write (cp.vect, cbd_pos, count / 4, 16);
+ cp.vect_size += count / 8;
+ if (count % 8)
+ cp.vect_size++;
+ mme_test_generate_end_cm_chan_est_ind (&cp);
+
+ /* Send and test MME. */
+ ce_rx_mme_send_cm_chan_est_ind
+ (&cp, &sta, tms, false, 5, default_tmi, tmi_list, &int_list);
+ } test_end;
+
+ /* Clean. */
+ tonemaps_release (tms);
}
int