1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-10-01 01:06:35 -04:00

DATV: external LDPC tool implementation (2)

This commit is contained in:
f4exb 2021-03-04 21:19:11 +01:00
parent 078e7fab37
commit 41e660c221
3 changed files with 28 additions and 12 deletions

View File

@ -1169,8 +1169,7 @@ void DATVDemodSink::InitDATVS2Framework()
*(leansdr::pipebuf< leansdr::fecframe<leansdr::llr_sb> > *) p_fecframes *(leansdr::pipebuf< leansdr::fecframe<leansdr::llr_sb> > *) p_fecframes
); );
// Decode FEC-protected frames into plain BB frames. // Decode FEC-protected frames into plain BB frames.
leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb> *r_fecdec = r_fecdec = new leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb>(
new leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb>(
m_objScheduler, m_objScheduler,
*(leansdr::pipebuf< leansdr::fecframe<leansdr::llr_sb> > *) p_fecframes, *(leansdr::pipebuf< leansdr::fecframe<leansdr::llr_sb> > *) p_fecframes,
*(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes, *(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes,
@ -1178,9 +1177,10 @@ void DATVDemodSink::InitDATVS2Framework()
p_vbitcount, p_vbitcount,
p_verrcount) p_verrcount)
; ;
const int nhelpers = 6; leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb> *fecdec = (leansdr::s2_fecdec_helper<leansdr::llr_t, leansdr::llr_sb> *) r_fecdec;
r_fecdec->nhelpers = nhelpers; const int nhelpers = 2;
r_fecdec->must_buffer = false; fecdec->nhelpers = nhelpers;
fecdec->must_buffer = false;
#endif #endif
} }
else else
@ -1194,7 +1194,8 @@ void DATVDemodSink::InitDATVS2Framework()
*(leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> > * ) p_fecframes *(leansdr::pipebuf< leansdr::fecframe<leansdr::hard_sb> > * ) p_fecframes
); );
r_fecdec = new leansdr::s2_fecdec<bool, leansdr::hard_sb>( 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, *(leansdr::pipebuf<leansdr::bbframe> *) p_bbframes,
p_vbitcount, p_vbitcount,
p_verrcount p_verrcount

View File

@ -168,10 +168,13 @@ int main(int argc, char **argv)
for (int i = 0; i < CODE_LEN; ++i) for (int i = 0; i < CODE_LEN; ++i)
code[(j + n) * CODE_LEN + i] = reinterpret_cast<ldpctool::code_type *>(simd + i)[n]; code[(j + n) * CODE_LEN + i] = reinterpret_cast<ldpctool::code_type *>(simd + i)[n];
if (count < 0) { if (count < 0)
{
iterations += blocks * trials; iterations += blocks * trials;
// std::cerr << "decoder failed at converging to a code word in " << trials << " trials" << std::endl; std::cerr << "ldpc_tool: decoder failed at converging to a code word in " << trials << " trials" << std::endl;
} else { }
else
{
iterations += blocks * (trials - count); iterations += blocks * (trials - count);
} }
} }

View File

@ -2411,36 +2411,46 @@ struct s2_fecdec_helper : runnable
s2_pls pls; s2_pls pls;
helper_instance *h; helper_instance *h;
}; };
simplequeue<helper_job, 1024> jobs; simplequeue<helper_job, 1024> jobs;
// Try to send a frame. Return false if helper was busy. // Try to send a frame. Return false if helper was busy.
bool send_frame(fecframe<SOFTBYTE> *pin) bool send_frame(fecframe<SOFTBYTE> *pin)
{ {
pool *p = get_pool(&pin->pls); pool *p = get_pool(&pin->pls);
for (int i = 0; i < p->nprocs; ++i) for (int i = 0; i < p->nprocs; ++i)
{ {
helper_instance *h = &p->procs[i]; helper_instance *h = &p->procs[i];
int iosize = (pin->pls.framebits() / 8) * sizeof(SOFTBYTE); int iosize = (pin->pls.framebits() / 8) * sizeof(SOFTBYTE);
// fprintf(stderr, "Writing %lu to fd %d\n", iosize, h->fd_tx); // fprintf(stderr, "Writing %lu to fd %d\n", iosize, h->fd_tx);
int nw = write(h->fd_tx, pin->bytes, iosize); int nw = write(h->fd_tx, pin->bytes, iosize);
if (nw < 0 && errno == EWOULDBLOCK) if (nw < 0 && errno == EWOULDBLOCK)
continue; continue; // next worker
if (nw < 0) if (nw < 0)
fatal("write(LDPC helper"); fatal("write(LDPC helper");
if (nw != iosize) if (nw != iosize)
fatal("partial write(LDPC helper)"); fatal("partial write(LDPC helper)");
helper_job *job = jobs.put(); helper_job *job = jobs.put();
job->pls = pin->pls; job->pls = pin->pls;
job->h = h; job->h = h;
++h->b_in; ++h->b_in;
if (h->b_in >= h->batch_size) if (h->b_in >= h->batch_size)
{ {
h->b_in -= h->batch_size; h->b_in -= h->batch_size;
h->b_out += 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. // Return a pool of running helpers for a given modcod.
pool *get_pool(const s2_pls *pls) pool *get_pool(const s2_pls *pls)
{ {
@ -2454,6 +2464,7 @@ struct s2_fecdec_helper : runnable
} }
return p; return p;
} }
// Spawn a helper process. // Spawn a helper process.
void spawn_helper(helper_instance *h, const s2_pls *pls) void spawn_helper(helper_instance *h, const s2_pls *pls)
{ {
@ -2554,6 +2565,7 @@ struct s2_fecdec_helper : runnable
if (sch->debug) if (sch->debug)
fprintf(stderr, "%c", corrupted ? '!' : ncorr ? '.' : '_'); fprintf(stderr, "%c", corrupted ? '!' : ncorr ? '.' : '_');
} }
pipereader<fecframe<SOFTBYTE>> in; pipereader<fecframe<SOFTBYTE>> in;
pipewriter<bbframe> out; pipewriter<bbframe> out;
const char *command; const char *command;