DATV: external LDPC tool implementation (3)

This commit is contained in:
f4exb 2021-03-05 08:25:26 +01:00
parent 41e660c221
commit a9e1e70ce4
1 changed files with 16 additions and 13 deletions

View File

@ -2367,29 +2367,30 @@ struct s2_fecdec_helper : runnable
} }
void run() void run()
{ {
bool work_done = false; in_count = out_count = 0;
// Send work until all helpers block. // Send work until all helpers block.
bool all_blocked = false;
while (in.readable() >= 1 && !jobs.full()) while (in.readable() >= 1 && !jobs.full())
{ {
if (!send_frame(in.rd())) if (!send_frame(in.rd())) {
{
all_blocked = true;
break; break;
} }
in.read(1); in.read(1);
work_done = true; in_count++;
} }
// Risk blocking on read() only when we have nothing else to do
// and we know a result is coming. while (
while ((all_blocked || !work_done || jobs.full()) && !jobs.empty() &&
!jobs.empty() && jobs.peek()->h->b_out &&
jobs.peek()->h->b_out && out.writable() >= 1 &&
out.writable() >= 1 && opt_writable(bitcount, 1) &&
opt_writable(bitcount, 1) && opt_writable(errcount, 1)) opt_writable(errcount, 1)
)
{ {
receive_frame(jobs.get()); receive_frame(jobs.get());
} }
fprintf(stderr, "s2_fecdec_helper::run: in=%d out=%d\n", in_count, out_count);
} }
private: private:
@ -2561,6 +2562,7 @@ struct s2_fecdec_helper : runnable
pout->pls = job->pls; pout->pls = job->pls;
bbscrambling.transform(hardbytes, fi->Kbch / 8, pout->bytes); bbscrambling.transform(hardbytes, fi->Kbch / 8, pout->bytes);
out.written(1); out.written(1);
out_count++;
} }
if (sch->debug) if (sch->debug)
fprintf(stderr, "%c", corrupted ? '!' : ncorr ? '.' : '_'); fprintf(stderr, "%c", corrupted ? '!' : ncorr ? '.' : '_');
@ -2574,6 +2576,7 @@ struct s2_fecdec_helper : runnable
s2_bch_engines s2bch; s2_bch_engines s2bch;
s2_bbscrambling bbscrambling; s2_bbscrambling bbscrambling;
pipewriter<int> *bitcount, *errcount; pipewriter<int> *bitcount, *errcount;
int in_count, out_count;
}; // s2_fecdec_helper }; // s2_fecdec_helper
// S2 FRAMER // S2 FRAMER