Skip to content
This repository has been archived by the owner on Mar 14, 2020. It is now read-only.

Commit

Permalink
Add L1-post scrambling.
Browse files Browse the repository at this point in the history
  • Loading branch information
drmpeg committed Dec 2, 2014
1 parent ad6434c commit c35652b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 13 deletions.
28 changes: 27 additions & 1 deletion grc/dvbt2_framemapper_cc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<key>dvbt2_framemapper_cc</key>
<category>dvbt2</category>
<import>import dvbt2</import>
<make>dvbt2.framemapper_cc($framesize.val, $rate.val, $constellation.val, $rotation.val, $fecblocks, $tiblocks, $carriermode.val, $fftsize.val, $guardinterval.val, $l1constellation.val, $pilotpattern.val, $t2frames, $numdatasyms, $paprmode.val, $version.val, $preamble.val, $inputmode.val, $reservedbiasbits.val)</make>
<make>dvbt2.framemapper_cc($framesize.val, $rate.val, $constellation.val, $rotation.val, $fecblocks, $tiblocks, $carriermode.val, $fftsize.val, $guardinterval.val, $l1constellation.val, $pilotpattern.val, $t2frames, $numdatasyms, $paprmode.val, $version.val, $preamble.val, $inputmode.val, $reservedbiasbits.val, $l1scrambled.val)</make>
<param>
<name>FECFRAME size</name>
<key>framesize</key>
Expand All @@ -23,6 +23,16 @@
<name>Code rate</name>
<key>rate</key>
<type>enum</type>
<option>
<name>1/3</name>
<key>C1_3</key>
<opt>val:dvbt2.C1_3</opt>
</option>
<option>
<name>2/5</name>
<key>C2_5</key>
<opt>val:dvbt2.C2_5</opt>
</option>
<option>
<name>1/2</name>
<key>C1_2</key>
Expand Down Expand Up @@ -378,6 +388,22 @@
<opt>val:dvbt2.RESERVED_ON</opt>
</option>
</param>
<param>
<name>L1-post Scrambling</name>
<key>l1scrambled</key>
<type>enum</type>
<hide>$version.hide_131</hide>
<option>
<name>Off</name>
<key>L1_SCRAMBLED_OFF</key>
<opt>val:dvbt2.L1_SCRAMBLED_OFF</opt>
</option>
<option>
<name>On</name>
<key>L1_SCRAMBLED_ON</key>
<opt>val:dvbt2.L1_SCRAMBLED_ON</opt>
</option>
</param>
<sink>
<name>in</name>
<type>complex</type>
Expand Down
12 changes: 9 additions & 3 deletions include/dvbt2/dvbt2_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
namespace gr {
namespace dvbt2 {
enum dvbt2_code_rate_t {
C1_3 = 0,
C2_5,
C1_2,
C1_2 = 0,
C3_5,
C2_3,
C3_4,
C4_5,
C5_6,
C1_3,
C2_5,
};

enum dvbt2_constellation_t {
Expand Down Expand Up @@ -169,6 +169,11 @@ namespace gr {
RESERVED_ON,
};

enum dvbt2_l1scrambled_t {
L1_SCRAMBLED_OFF = 0,
L1_SCRAMBLED_ON,
};

} // namespace dvbt2
} // namespace gr

Expand All @@ -187,6 +192,7 @@ typedef gr::dvbt2::dvbt2_l1constellation_t dvbt2_l1constellation_t;
typedef gr::dvbt2::dvbt2_pilotpattern_t dvbt2_pilotpattern_t;
typedef gr::dvbt2::dvbt2_version_t dvbt2_version_t;
typedef gr::dvbt2::dvbt2_reservedbiasbits_t dvbt2_reservedbiasbits_t;
typedef gr::dvbt2::dvbt2_l1scrambled_t dvbt2_l1scrambled_t;

#endif /* INCLUDED_DVBT2_CONFIG_H */

2 changes: 1 addition & 1 deletion include/dvbt2/framemapper_cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace gr {
* class. dvbt2::framemapper_cc::make is the public interface for
* creating new instances.
*/
static sptr make(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits);
static sptr make(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits, dvbt2_l1scrambled_t l1scrambled);
};

} // namespace dvbt2
Expand Down
35 changes: 28 additions & 7 deletions lib/framemapper_cc_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ namespace gr {
namespace dvbt2 {

framemapper_cc::sptr
framemapper_cc::make(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits)
framemapper_cc::make(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits, dvbt2_l1scrambled_t l1scrambled)
{
return gnuradio::get_initial_sptr
(new framemapper_cc_impl(framesize, rate, constellation, rotation, fecblocks, tiblocks, carriermode, fftsize, guardinterval, l1constellation, pilotpattern, t2frames, numdatasyms, paprmode, version, preamble, inputmode, reservedbiasbits));
(new framemapper_cc_impl(framesize, rate, constellation, rotation, fecblocks, tiblocks, carriermode, fftsize, guardinterval, l1constellation, pilotpattern, t2frames, numdatasyms, paprmode, version, preamble, inputmode, reservedbiasbits, l1scrambled));
}

/*
* The private constructor
*/
framemapper_cc_impl::framemapper_cc_impl(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits)
framemapper_cc_impl::framemapper_cc_impl(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits, dvbt2_l1scrambled_t l1scrambled)
: gr::block("framemapper_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
Expand Down Expand Up @@ -84,9 +84,9 @@ namespace gr {
break;
}
}
fef_present = FALSE;
fef_length = 1124864;
fef_interval = 1;
fef_present = FALSE; /* for testing only */
fef_length = 134144; /* " " " */
fef_interval = 1; /* " " " */
l1preinit->type = gr::dvbt2::STREAMTYPE_TS;
l1preinit->bwt_ext = carriermode;
l1preinit->s1 = preamble;
Expand Down Expand Up @@ -117,7 +117,7 @@ namespace gr {
l1preinit->num_rf = 1;
l1preinit->current_rf_index = 0;
l1preinit->t2_version = version;
l1preinit->l1_post_scrambled = FALSE;
l1preinit->l1_post_scrambled = l1scrambled;
l1preinit->t2_base_lite = FALSE;
if (reservedbiasbits == gr::dvbt2::RESERVED_OFF)
{
Expand Down Expand Up @@ -1132,6 +1132,7 @@ namespace gr {
fft_size = fftsize;
t2_frames = t2frames;
t2_frame_num = 0;
l1_scrambled = l1scrambled;
if (N_FC == 0)
{
set_output_multiple((N_P2 * C_P2) + (numdatasyms * C_DATA));
Expand Down Expand Up @@ -1160,6 +1161,7 @@ namespace gr {
exit(1);
}
init_dummy_randomizer();
init_l1_randomizer();
}

/*
Expand Down Expand Up @@ -1757,6 +1759,13 @@ void framemapper_cc_impl::add_l1post(gr_complex *out, int t2_frame_num)
l1post[offset_bits++] = temp & (1 << n) ? 1 : 0;
}
offset_bits += add_crc32_bits(l1post, offset_bits);
if (l1_scrambled == TRUE)
{
for (int n = 0; n < offset_bits; n++)
{
l1post[n] = l1post[n] ^ l1_randomize[n];
}
}
/* Padding */
switch (l1_constellation)
{
Expand Down Expand Up @@ -2029,6 +2038,18 @@ void framemapper_cc_impl::init_dummy_randomizer(void)
}
}

void framemapper_cc_impl::init_l1_randomizer(void)
{
int sr = 0x4A80;
for (int i = 0; i < KBCH_1_2; i++)
{
int b = ((sr) ^ (sr >> 1)) & 1;
l1_randomize[i] = b;
sr >>= 1;
if(b) sr |= 0x4000;
}
}

int
framemapper_cc_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
Expand Down
5 changes: 4 additions & 1 deletion lib/framemapper_cc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace gr {
int eta_mod;
int t2_frames;
int t2_frame_num;
int l1_scrambled;
int fef_present;
int fef_length;
int fef_interval;
Expand All @@ -160,11 +161,13 @@ namespace gr {
void l1pre_ldpc_lookup_generate(void);
void l1post_ldpc_lookup_generate(void);
void init_dummy_randomizer(void);
void init_l1_randomizer(void);
l1pre_ldpc_encode_table l1pre_ldpc_encode;
l1post_ldpc_encode_table l1post_ldpc_encode;
unsigned char l1_temp[FRAME_SIZE_SHORT];
unsigned char l1_interleave[FRAME_SIZE_SHORT];
unsigned char l1_map[KBCH_1_2];
unsigned char l1_randomize[KBCH_1_2];
gr_complex *zigzag_interleave;
gr_complex *dummy_randomize;
gr_complex l1pre_cache[1840];
Expand All @@ -189,7 +192,7 @@ namespace gr {
const static int mux64[12];

public:
framemapper_cc_impl(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits);
framemapper_cc_impl(dvbt2_framesize_t framesize, dvbt2_code_rate_t rate, dvbt2_constellation_t constellation, dvbt2_rotation_t rotation, int fecblocks, int tiblocks, dvbt2_extended_carrier_t carriermode, dvbt2_fftsize_t fftsize, dvbt2_guardinterval_t guardinterval, dvbt2_l1constellation_t l1constellation, dvbt2_pilotpattern_t pilotpattern, int t2frames, int numdatasyms, dvbt2_papr_t paprmode, dvbt2_version_t version, dvbt2_preamble_t preamble, dvbt2_inputmode_t inputmode, dvbt2_reservedbiasbits_t reservedbiasbits, dvbt2_l1scrambled_t l1scrambled);
~framemapper_cc_impl();

// Where all the action really happens
Expand Down

0 comments on commit c35652b

Please sign in to comment.