/** Runs the clip depending on the current data path and transfer state. For example, fills the sink buffer if TDataPathState is EPlaying and TTransferState is ENeedSinkData. */ void CMMFDataPath2::RunL() { #ifdef _DP_DEBUG RDebug::Print(_L("DP::RunL transfer state %d, iPausedCalled %d, tick-%d (this 0x%x)\n"),iTransferState, iPauseCalled, User::TickCount(),this); #endif switch (iState) { case EStopped: break; case EPrimed: // In the paused state we still continue to feed buffers to the sink. The sink (DevSound) handles the logic of whether the buffers should be emptied { if (!iPauseCalled || !iIsUsingResumeSupport) break; } // fall-through case EPlaying: case ERecording: case EConverting: switch (iTransferState) { case EWaitSink: case EWaitSource: break; case EInitializeSink: InitializeSinkL(); break; case EInitializeSource: InitializeSourceL(); break; case ENeedSourceData: FillSourceBufferL(); break; case ENeedSinkData: FillSinkBufferL(); break; case ENeedToMatchSourceToSink: FillSinkBufferL(); break; case ESendDataToSink: EmptySinkBufferL(); break; case EEndOfData: EndOfData(); break; } break; default: break; } #ifdef _DP_DEBUG RDebug::Print(_L("DP::RunL DONE\n")); #endif }
/* Expand group-3 2-dimensional data */ void g32expand(struct pagenode *pn, drawfunc df) { int RunLength; /* Length of current run */ int a0; /* reference element */ int b1; /* next change on previous line */ int lastx = pn->size.width();/* copy line width to register */ pixnum *run0, *run1; /* run length arrays */ pixnum *thisrun, *pa, *pb; /* pointers into runs */ t16bits *sp; /* pointer into compressed data */ t32bits BitAcc; /* bit accumulator */ int BitsAvail; /* # valid bits in BitAcc */ int EOLcnt; /* number of consecutive EOLs */ int refline = 0; /* 1D encoded reference line */ int LineNum; /* line number */ struct tabent *TabEnt; sp = pn->data; BitAcc = 0; BitsAvail = 0; /* allocate space for 2 runlength arrays */ run0 = (pixnum *) malloc(2 * ((lastx+5)&~1) * sizeof(pixnum)); run1 = run0 + ((lastx+5)&~1); run1[0] = lastx; run1[1] = 0; EOLcnt = 0; for (LineNum = 0; LineNum < pn->rowsperstrip; ) { #ifdef DEBUG_FAX printf("\nBitAcc=%08lX, BitsAvail = %d\n", BitAcc, BitsAvail); printf("-------------------- %d\n", LineNum); fflush(stdout); #endif if (EOLcnt == 0) while (!EndOfData(pn)) { /* skip over garbage after a coding error */ NeedBits(11); if (GetBits(11) == 0) break; ClrBits(1); } for (EOLcnt = 1; !EndOfData(pn); EOLcnt++) { /* we have seen 11 zeros, which implies EOL, skip possible fill bits too */ while (1) { NeedBits(8); if (GetBits(8)) break; ClrBits(8); } while (GetBits(1) == 0) ClrBits(1); ClrBits(1); /* the eol flag */ NeedBits(12); refline = GetBits(1); /* 1D / 2D flag */ ClrBits(1); if (GetBits(11)) break; ClrBits(11); } if (EOLcnt > 1 && EOLcnt != 6 && verbose) kError() << "Line " << LineNum << ": bad RTC (" << EOLcnt << " EOLs)\n"; if (EOLcnt >= 6 || EndOfData(pn)) { free(run0); return; } if (LineNum == 0 && refline == 0 && verbose) kDebug() << "First line is 2-D encoded\n"; RunLength = 0; if (LineNum & 1) { pa = run1; pb = run0; } else { pa = run0; pb = run1; } thisrun = pa; EOLcnt = 0; a0 = 0; b1 = *pb++; if (refline) { expand1d(); } else { expand2d(EOL2); } if (RunLength) SETVAL(0); if (a0 != lastx) { if (verbose) kWarning() << "Line " << LineNum << ": length is " << a0 << " (expected "<< lastx << ")\n"; while (a0 > lastx) a0 -= *--pa; if (a0 < lastx) { if ((pa - run0) & 1) SETVAL(0); SETVAL(lastx - a0); } } SETVAL(0); /* imaginary change at end of line for reference */ (*df)(thisrun, LineNum++, pn); } free(run0); }
/* Expand group-3 1-dimensional data */ void g31expand(struct pagenode *pn, drawfunc df) { int a0; /* reference element */ int lastx; /* copy line width to register */ t32bits BitAcc; /* bit accumulator */ int BitsAvail; /* # valid bits in BitAcc */ int RunLength; /* Length of current run */ t16bits *sp; /* pointer into compressed data */ pixnum *pa; /* pointer into new line */ int EOLcnt; /* number of consecutive EOLs */ int LineNum; /* line number */ pixnum *runs; /* list of run lengths */ struct tabent *TabEnt; sp = pn->data; BitAcc = 0; BitsAvail = 0; lastx = pn->size.width(); runs = (pixnum *) malloc(lastx * sizeof(pixnum)); EOLcnt = 0; for (LineNum = 0; LineNum < pn->rowsperstrip; ) { #ifdef DEBUG_FAX fprintf(stderr,"\nBitAcc=%08lX, BitsAvail = %d\n", BitAcc, BitsAvail); fprintf(stderr,"-------------------- %d\n", LineNum); fflush(stderr); #endif if (EOLcnt == 0) while (!EndOfData(pn)) { /* skip over garbage after a coding error */ NeedBits(11); if (GetBits(11) == 0) break; ClrBits(1); } for (EOLcnt = 1; !EndOfData(pn); EOLcnt++) { /* we have seen 11 zeros, which implies EOL, skip possible fill bits too */ while (1) { NeedBits(8); if (GetBits(8)) break; ClrBits(8); } while (GetBits(1) == 0) ClrBits(1); ClrBits(1); /* the eol flag */ NeedBits(11); if (GetBits(11)) break; ClrBits(11); } if (EOLcnt > 1 && EOLcnt != 6 && verbose) { kError() << "Line " << LineNum << ": bad RTC (" << EOLcnt << " EOLs)\n"; } if (EOLcnt >= 6 || EndOfData(pn)) { free(runs); return; } RunLength = 0; pa = runs; a0 = 0; EOLcnt = 0; expand1d(); if (RunLength) SETVAL(0); if (a0 != lastx) { if (verbose) kWarning() << "Line " << LineNum << ": length is " << a0 << " (expected "<< lastx << ")\n"; while (a0 > lastx) a0 -= *--pa; if (a0 < lastx) { if ((pa - runs) & 1) SETVAL(0); SETVAL(lastx - a0); } } (*df)(runs, LineNum++, pn); } free(runs); }