From c6f31e2719d60dba8a68ea24d64d702a5ff7c9ed Mon Sep 17 00:00:00 2001 From: dufour Date: Thu, 16 Jul 2009 09:13:11 +0000 Subject: * 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 --- cesar/ce/rx/cp/test/src/test_mme.c | 160 +++++++++++++++++++++++++++++++++++-- 1 file changed, 155 insertions(+), 5 deletions(-) (limited to 'cesar/ce/rx/cp/test') 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 -- cgit v1.2.3