Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/dvbs2-rx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DVBS2RxTopBlock(gr.top_block, Qt.QWidget):
self.ldpc_iterations = options.ldpc_iterations
self.modcod = options.modcod
self.multistream = options.multistream
self.multistream_isi = options.multistream_isi
self.out_fd = options.out_fd
self.out_file = options.out_file
self.out_stream = options.out_stream
Expand Down Expand Up @@ -866,7 +867,7 @@ class DVBS2RxTopBlock(gr.top_block, Qt.QWidget):
bbdescrambler = dvbs2rx.bbdescrambler_bb(standard, frame_size,
code_rate)
bbdeheader = dvbs2rx.bbdeheader_bb(standard, frame_size, code_rate,
self.debug)
self.multistream_isi, self.debug)

self.connect((ldpc_decoder, 0), (bch_decoder, 0), (bbdescrambler, 0))

Expand Down Expand Up @@ -1234,6 +1235,12 @@ def argument_parser():
help="Enable processing of multiple input streams (MIS mode). Set to "
"\"auto\" if unsure about whether the input signal uses SIS or MIS. "
"Otherwise, choose \"on\" or \"off\" for better performance.")
dvb_group.add_argument(
"--multistream-isi",
type=int,
default=0,
help="Select which stream to process when operating in MIS mode and "
"output stream is MPEG TS.")
dvb_group.add_argument(
'-p',
"--pilots",
Expand Down
1 change: 1 addition & 0 deletions include/gnuradio/dvbs2rx/bbdeheader_bb.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DVBS2RX_API bbdeheader_bb : virtual public gr::block
static sptr make(dvb_standard_t standard,
dvb_framesize_t framesize,
dvb_code_rate_t rate,
int multistream_isi = 0,
int debug_level = 0);

/*!
Expand Down
40 changes: 32 additions & 8 deletions lib/bbdeheader_bb_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ namespace dvbs2rx {
bbdeheader_bb::sptr bbdeheader_bb::make(dvb_standard_t standard,
dvb_framesize_t framesize,
dvb_code_rate_t rate,
int multistream_isi,
int debug_level)
{
return gnuradio::get_initial_sptr(
new bbdeheader_bb_impl(standard, framesize, rate, debug_level));
new bbdeheader_bb_impl(standard, framesize, rate, multistream_isi, debug_level));
}

/*
Expand All @@ -39,13 +40,15 @@ bbdeheader_bb::sptr bbdeheader_bb::make(dvb_standard_t standard,
bbdeheader_bb_impl::bbdeheader_bb_impl(dvb_standard_t standard,
dvb_framesize_t framesize,
dvb_code_rate_t rate,
int multistream_isi,
int debug_level)
: gr::block("bbdeheader_bb",
gr::io_signature::make(1, 1, sizeof(unsigned char)),
gr::io_signature::make(1, 1, sizeof(unsigned char))),
d_debug_level(debug_level),
d_synched(false),
d_partial_ts_bytes(0),
d_multistream_isi(multistream_isi),
d_packet_cnt(0),
d_error_cnt(0),
d_bbframe_cnt(0),
Expand All @@ -57,6 +60,7 @@ bbdeheader_bb_impl::bbdeheader_bb_impl(dvb_standard_t standard,
get_fec_info(standard, framesize, rate, fec_info);
d_kbch_bytes = fec_info.bch.k / 8;
d_max_dfl = fec_info.bch.k - BB_HEADER_LENGTH_BITS;
d_up_length = TS_PACKET_LENGTH;
set_output_multiple(d_max_dfl / 8); // ensure full BBFRAMEs on the input
}

Expand Down Expand Up @@ -121,8 +125,22 @@ bool bbdeheader_bb_impl::parse_bbheader(u8_cptr_t in, BBHeader* h)
return false;
}

if (h->upl != (TS_PACKET_LENGTH * 8)) {
d_logger->warn("Baseband header unsupported (upl != 188 bytes).");
// UP length depends on NPD and ISSY features, moreover ISSY ISCR counter
// may be short (2 bytes) or long (3 bytes) format
if ((h->issyi == 1) || (h->npd == 1)) {
d_up_length = h->upl / 8;
if (h->npd == 1) {
d_logger->warn("Baseband header unsupported (npd not implemented).");
return false;
}
if ((h->issyi == 1) &&
(d_up_length != (TS_PACKET_LENGTH + 2)) &&
(d_up_length != (TS_PACKET_LENGTH + 3))) {
d_logger->warn("Baseband header unsupported (invalid issy upl).");
return false;
}
} else if (h->upl != (d_up_length * 8)) {
d_logger->warn("Baseband header unsupported (invalid upl).");
return false;
}

Expand Down Expand Up @@ -184,6 +202,12 @@ int bbdeheader_bb_impl::general_work(int noutput_items,
d_bbheader.sync,
d_bbheader.syncd);

// Limit processing to user-specified ISI BBFRAMEs only
if ((d_bbheader.sis_mis == 0) && (d_bbheader.isi != d_multistream_isi)) {
in += d_kbch_bytes;
continue;
}

// Skip the BBHEADER
in += BB_HEADER_LENGTH_BYTES;
unsigned int df_remaining = d_bbheader.dfl / 8; // DATAFIELD bytes remaining
Expand All @@ -199,23 +223,23 @@ int bbdeheader_bb_impl::general_work(int noutput_items,
}

// Process the TS packets available on the DATAFIELD
while (df_remaining >= TS_PACKET_LENGTH) {
while (df_remaining >= d_up_length) {
u8_cptr_t packet;
// Start by completing a partial TS packet from the previous BBFRAME (if any)
if (d_partial_ts_bytes > 0) {
unsigned int remaining = TS_PACKET_LENGTH - d_partial_ts_bytes;
unsigned int remaining = d_up_length - d_partial_ts_bytes;
memcpy(d_partial_pkt + d_partial_ts_bytes, in, remaining);
d_partial_ts_bytes = 0; // Reset the count
in += remaining;
df_remaining -= remaining;
packet = d_partial_pkt;
} else {
packet = in;
in += TS_PACKET_LENGTH;
df_remaining -= TS_PACKET_LENGTH;
in += d_up_length;
df_remaining -= d_up_length;
}

const bool crc_valid = check_crc8(packet, TS_PACKET_LENGTH);
const bool crc_valid = check_crc8(packet, d_up_length);
out[0] = MPEG_TS_SYNC_BYTE; // Restore the sync byte
memcpy(out + 1, packet, TS_PACKET_LENGTH - 1);
if (!crc_valid) {
Expand Down
5 changes: 4 additions & 1 deletion lib/bbdeheader_bb_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class bbdeheader_bb_impl : public bbdeheader_bb
const int d_debug_level; /**< Debug level*/
unsigned int d_kbch_bytes; /**< BBFRAME length in bytes */
unsigned int d_max_dfl; /**< Maximum DATAFIELD length in bits */
unsigned int d_up_length; /**< User-packet length in bytes */
bool d_synched; /**< Synchronized to the start of TS packets */
unsigned int d_partial_ts_bytes; /**< Byte count of the partial TS packet
extracted at the end of the previous BBFRAME */
unsigned char d_partial_pkt[TS_PACKET_LENGTH]; /**< Partial TS packet storage */
unsigned char d_partial_pkt[TS_PACKET_LENGTH+3]; /**< Partial TS packet storage */
const int d_multistream_isi; /**< ISI to process in MIS mode */
BBHeader d_bbheader; /**< Parsed BBHEADER */
uint64_t d_packet_cnt; /**< All-time count of received packets */
uint64_t d_error_cnt; /**< All-time count of packets with bit errors */
Expand Down Expand Up @@ -75,6 +77,7 @@ class bbdeheader_bb_impl : public bbdeheader_bb
bbdeheader_bb_impl(dvb_standard_t standard,
dvb_framesize_t framesize,
dvb_code_rate_t rate,
int multistream_isi,
int debug_level);
~bbdeheader_bb_impl();

Expand Down
3 changes: 2 additions & 1 deletion python/dvbs2rx/bindings/bbdeheader_bb_python.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* BINDTOOL_GEN_AUTOMATIC(0) */
/* BINDTOOL_USE_PYGCCXML(0) */
/* BINDTOOL_HEADER_FILE(bbdeheader_bb.h) */
/* BINDTOOL_HEADER_FILE_HASH(578413664762f19a0cacbaaec4388df9) */
/* BINDTOOL_HEADER_FILE_HASH(2d9af3280cbe04ac25b1099852ed6091) */
/***********************************************************************************/

#include <pybind11/complex.h>
Expand All @@ -40,6 +40,7 @@ void bind_bbdeheader_bb(py::module& m)
py::arg("standard"),
py::arg("framesize"),
py::arg("rate"),
py::arg("multistream_isi") = 0,
py::arg("debug_level") = 0,
D(bbdeheader_bb, make))

Expand Down