mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 18:15:45 -05:00
DATV: external LDPC tool implementation (2)
This commit is contained in:
parent
078e7fab37
commit
41e660c221
@ -1169,8 +1169,7 @@ void DATVDemodSink::InitDATVS2Framework()
|
||||
*(leansdr::pipebuf< leansdr::fecframe<leansdr::llr_sb> > *) p_fecframes
|
||||
);
|
||||
// Decode FEC-protected frames into plain BB frames.
|
||||
leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb> *r_fecdec =
|
||||
new leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb>(
|
||||
r_fecdec = new leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb>(
|
||||
m_objScheduler,
|
||||
*(leansdr::pipebuf< leansdr::fecframe<leansdr::llr_sb> > *) p_fecframes,
|
||||
*(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes,
|
||||
@ -1178,9 +1177,10 @@ void DATVDemodSink::InitDATVS2Framework()
|
||||
p_vbitcount,
|
||||
p_verrcount)
|
||||
;
|
||||
const int nhelpers = 6;
|
||||
r_fecdec->nhelpers = nhelpers;
|
||||
r_fecdec->must_buffer = false;
|
||||
leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb> *fecdec = (leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb> *) r_fecdec;
|
||||
const int nhelpers = 2;
|
||||
fecdec->nhelpers = nhelpers;
|
||||
fecdec->must_buffer = false;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -1194,7 +1194,8 @@ void DATVDemodSink::InitDATVS2Framework()
|
||||
*(leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> > * ) p_fecframes
|
||||
);
|
||||
r_fecdec = new leansdr::s2_fecdec<bool, leansdr::hard_sb>(
|
||||
m_objScheduler, *(leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> > * ) p_fecframes,
|
||||
m_objScheduler,
|
||||
*(leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> > * ) p_fecframes,
|
||||
*(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes,
|
||||
p_vbitcount,
|
||||
p_verrcount
|
||||
|
@ -168,10 +168,13 @@ int main(int argc, char **argv)
|
||||
for (int i = 0; i < CODE_LEN; ++i)
|
||||
code[(j + n) * CODE_LEN + i] = reinterpret_cast<ldpctool::code_type *>(simd + i)[n];
|
||||
|
||||
if (count < 0) {
|
||||
if (count < 0)
|
||||
{
|
||||
iterations += blocks * trials;
|
||||
// std::cerr << "decoder failed at converging to a code word in " << trials << " trials" << std::endl;
|
||||
} else {
|
||||
std::cerr << "ldpc_tool: decoder failed at converging to a code word in " << trials << " trials" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterations += blocks * (trials - count);
|
||||
}
|
||||
}
|
||||
|
@ -2411,36 +2411,46 @@ struct s2_fecdec_helper : runnable
|
||||
s2_pls pls;
|
||||
helper_instance *h;
|
||||
};
|
||||
|
||||
simplequeue<helper_job, 1024> jobs;
|
||||
|
||||
// Try to send a frame. Return false if helper was busy.
|
||||
bool send_frame(fecframe<SOFTBYTE> *pin)
|
||||
{
|
||||
pool *p = get_pool(&pin->pls);
|
||||
|
||||
for (int i = 0; i < p->nprocs; ++i)
|
||||
{
|
||||
helper_instance *h = &p->procs[i];
|
||||
int iosize = (pin->pls.framebits() / 8) * sizeof(SOFTBYTE);
|
||||
// fprintf(stderr, "Writing %lu to fd %d\n", iosize, h->fd_tx);
|
||||
int nw = write(h->fd_tx, pin->bytes, iosize);
|
||||
|
||||
if (nw < 0 && errno == EWOULDBLOCK)
|
||||
continue;
|
||||
continue; // next worker
|
||||
if (nw < 0)
|
||||
fatal("write(LDPC helper");
|
||||
if (nw != iosize)
|
||||
fatal("partial write(LDPC helper)");
|
||||
|
||||
helper_job *job = jobs.put();
|
||||
job->pls = pin->pls;
|
||||
job->h = h;
|
||||
++h->b_in;
|
||||
|
||||
if (h->b_in >= h->batch_size)
|
||||
{
|
||||
h->b_in -= h->batch_size;
|
||||
h->b_out += h->batch_size;
|
||||
}
|
||||
return true;
|
||||
|
||||
return true; // done sent to worker
|
||||
}
|
||||
return false;
|
||||
|
||||
fprintf(stderr, "s2_fecdec_helper::send_frame: WARNING: all %d workers are busy\n", p->nprocs);
|
||||
return false; // all workers are busy
|
||||
}
|
||||
|
||||
// Return a pool of running helpers for a given modcod.
|
||||
pool *get_pool(const s2_pls *pls)
|
||||
{
|
||||
@ -2454,6 +2464,7 @@ struct s2_fecdec_helper : runnable
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
// Spawn a helper process.
|
||||
void spawn_helper(helper_instance *h, const s2_pls *pls)
|
||||
{
|
||||
@ -2554,6 +2565,7 @@ struct s2_fecdec_helper : runnable
|
||||
if (sch->debug)
|
||||
fprintf(stderr, "%c", corrupted ? '!' : ncorr ? '.' : '_');
|
||||
}
|
||||
|
||||
pipereader<fecframe<SOFTBYTE>> in;
|
||||
pipewriter<bbframe> out;
|
||||
const char *command;
|
||||
|
Loading…
Reference in New Issue
Block a user