void TwoDimensionalPlotPage::plotPhase(QualityTablesFormatter::StatisticKind kind, unsigned polarization) { std::ostringstream s; s << "Polarization " << polarization; StartLine(_plot, s.str(), getYDesc()); StatisticsDerivator derivator(*_statCollection); const std::map<double, DefaultStatistics> &statistics = GetStatistics(); for(std::map<double, DefaultStatistics>::const_iterator i=statistics.begin();i!=statistics.end();++i) { const double x = i->first; const std::complex<long double> val = derivator.GetComplexStatistic(kind, i->second, polarization); _plot.PushDataPoint(x, getValue<Phase>(val)); } }
void DbgInfoLine (void) /* Parse and handle LINE subcommand of the .dbg pseudo instruction */ { long Line; FilePos Pos = STATIC_FILEPOS_INITIALIZER; /* Any new line info terminates the last one */ if (CurLineInfo) { EndLine (CurLineInfo); CurLineInfo = 0; } /* If a parameters follow, this is actual line info. If no parameters ** follow, the last line info is terminated. */ if (CurTok.Tok == TOK_SEP) { return; } /* Parameters are separated by a comma */ ConsumeComma (); /* The name of the file follows */ if (CurTok.Tok != TOK_STRCON) { ErrorSkip ("String constant expected"); return; } /* Get the index in the file table for the name */ Pos.Name = GetFileIndex (&CurTok.SVal); /* Skip the name */ NextTok (); /* Comma expected */ ConsumeComma (); /* Line number */ Line = ConstExpression (); if (Line < 0) { ErrorSkip ("Line number is out of valid range"); return; } Pos.Line = Line; /* Generate a new external line info */ CurLineInfo = StartLine (&Pos, LI_TYPE_EXT, 0); }
/// SingleComponentLSScan::ParseMCU // Parse a single MCU in this scan. Return true if there are more // MCUs in this row. bool SingleComponentLSScan::ParseMCU(void) { #if ACCUSOFT_CODE int lines = m_ulRemaining[0]; // total number of MCU lines processed. UBYTE preshift = m_ucLowBit + FractionalColorBitsOf(); struct Line *line = CurrentLine(0); // // If a DNL marker is present, the number of remaining lines is zero. Fix it. if (m_pFrame->HeightOf() == 0) { assert(lines == 0); lines = 8; } assert(m_ucCount == 1); // // A "MCU" in respect to the code organization is eight lines. if (lines > 8) { lines = 8; } if (m_pFrame->HeightOf() > 0) m_ulRemaining[0] -= lines; assert(lines > 0); // Loop over lines and columns do { LONG length = m_ulWidth[0]; LONG *lp = line->m_pData; #ifdef DEBUG_LS int xpos = 0; static int linenumber = 0; printf("\n%4d : ",++linenumber); #endif StartLine(0); if (BeginReadMCU(m_Stream.ByteStreamOf())) { // No error handling strategy. No RST in scans. Bummer! do { LONG a,b,c,d; // neighbouring values. LONG d1,d2,d3; // local gradients. GetContext(0,a,b,c,d); d1 = d - b; // compute local gradients d2 = b - c; d3 = c - a; if (isRunMode(d1,d2,d3)) { LONG run = DecodeRun(length,m_lRunIndex[0]); // // Now fill the data. while(run) { // Update so that the next process gets the correct value. UpdateContext(0,a); // And insert the value into the target line as well. *lp++ = a << preshift; #ifdef DEBUG_LS printf("%4d:<%2x> ",xpos++,a); #endif run--,length--; // As long as there are pixels on the line. } // // More data on the line? I.e. the run did not cover the full m_lJ samples? // Now decode the run interruption sample. if (length) { bool negative; // the sign variable bool rtype; // run interruption type LONG errval; // the prediction error LONG merr; // the mapped error (symbol) LONG rx; // the reconstructed value UBYTE k; // golomb parameter // Get the neighbourhood. GetContext(0,a,b,c,d); // Get the prediction mode. rtype = InterruptedPredictionMode(negative,a,b); // Get the golomb parameter for run interruption coding. k = GolombParameter(rtype); // Golomb-decode the error symbol. merr = GolombDecode(k,m_lLimit - m_lJ[m_lRunIndex[0]] - 1); // Inverse the error mapping procedure. errval = InverseErrorMapping(merr + rtype,ErrorMappingOffset(rtype,rtype || merr,k)); // Compute the reconstructed value. rx = Reconstruct(negative,rtype?a:b,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // Fill in the value into the line *lp = rx << preshift; #ifdef DEBUG_LS printf("%4d:<%2x> ",xpos++,*lp); #endif // Update the variables of the run mode. UpdateState(rtype,errval); // Update the run index now. This is not part of // EncodeRun because the non-reduced run-index is // required for the golomb coder length limit. if (m_lRunIndex[0] > 0) m_lRunIndex[0]--; } else break; // end of line. } else { UWORD ctxt; bool negative; // the sign variable. LONG px; // the predicted variable. LONG rx; // the reconstructed value. LONG errval; // the error value. LONG merr; // the mapped error value. UBYTE k; // the Golomb parameter. // Quantize the gradients. d1 = QuantizedGradient(d1); d2 = QuantizedGradient(d2); d3 = QuantizedGradient(d3); // Compute the context. ctxt = Context(negative,d1,d2,d3); // Compute the predicted value. px = Predict(a,b,c); // Correct the prediction. px = CorrectPrediction(ctxt,negative,px); // Compute the golomb parameter k from the context. k = GolombParameter(ctxt); // Decode the error symbol. merr = GolombDecode(k,m_lLimit); // Inverse the error symbol into an error value. errval = InverseErrorMapping(merr,ErrorMappingOffset(ctxt,k)); // Update the variables. UpdateState(ctxt,errval); // Compute the reconstructed value. rx = Reconstruct(negative,px,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // And insert the value into the target line as well. *lp = rx << preshift; #ifdef DEBUG_LS printf("%4d:<%2x> ",xpos++,*lp); #endif } } while(++lp,--length); } // No error handling here. EndLine(0); line = line->m_pNext; } while(--lines); // // If this is the last line, gobble up all the // bits from bitstuffing the last byte may have left. // As SkipStuffing is idempotent, we can also do that // all the time. m_Stream.SkipStuffing(); #endif return false; }
/// SingleComponentLSScan::WriteMCU // Write a single MCU in this scan. bool SingleComponentLSScan::WriteMCU(void) { #if ACCUSOFT_CODE int lines = m_ulRemaining[0]; // total number of MCU lines processed. UBYTE preshift = m_ucLowBit + FractionalColorBitsOf(); struct Line *line = CurrentLine(0); assert(m_ucCount == 1); // // A "MCU" in respect to the code organization is eight lines. if (lines > 8) { lines = 8; } m_ulRemaining[0] -= lines; assert(lines > 0); // Loop over lines and columns do { LONG length = m_ulWidth[0]; LONG *lp = line->m_pData; BeginWriteMCU(m_Stream.ByteStreamOf()); // MCU is a single line. StartLine(0); do { LONG a,b,c,d,x; // neighbouring values. LONG d1,d2,d3; // local gradients. GetContext(0,a,b,c,d); x = *lp >> preshift; d1 = d - b; // compute local gradients d2 = b - c; d3 = c - a; if (isRunMode(d1,d2,d3)) { LONG runval = a; LONG runcnt = 0; do { x = *lp >> preshift; if (x - runval < -m_lNear || x - runval > m_lNear) break; // Update so that the next process gets the correct value. // Also updates the line pointers. UpdateContext(0,runval); } while(lp++,runcnt++,--length); // Encode the run. Depends on whether the run was interrupted // by the end of the line. EncodeRun(runcnt,length == 0,m_lRunIndex[0]); // Continue the encoding of the end of the run if there are more // samples to encode. if (length) { bool negative; // the sign variable bool rtype; // run interruption type LONG errval; // the prediction error LONG merr; // the mapped error (symbol) LONG rx; // the reconstructed value UBYTE k; // golomb parameter // Get the neighbourhood. GetContext(0,a,b,c,d); // Get the prediction mode. rtype = InterruptedPredictionMode(negative,a,b); // Compute the error value. errval = x - ((rtype)?(a):(b)); if (negative) errval = -errval; // Quantize the error. errval = QuantizePredictionError(errval); // Compute the reconstructed value. rx = Reconstruct(negative,rtype?a:b,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // Get the golomb parameter for run interruption coding. k = GolombParameter(rtype); // Map the error into a symbol. merr = ErrorMapping(errval,ErrorMappingOffset(rtype,errval != 0,k)) - rtype; // Golomb-coding of the error. GolombCode(k,merr,m_lLimit - m_lJ[m_lRunIndex[0]] - 1); // Update the variables of the run mode. UpdateState(rtype,errval); // Update the run index now. This is not part of // EncodeRun because the non-reduced run-index is // required for the golomb coder length limit. if (m_lRunIndex[0] > 0) m_lRunIndex[0]--; } else break; // Line ended, abort the loop over the line. } else { UWORD ctxt; bool negative; // the sign variable. LONG px; // the predicted variable. LONG rx; // the reconstructed value. LONG errval; // the error value. LONG merr; // the mapped error value. UBYTE k; // the Golomb parameter. // Quantize the gradients. d1 = QuantizedGradient(d1); d2 = QuantizedGradient(d2); d3 = QuantizedGradient(d3); // Compute the context. ctxt = Context(negative,d1,d2,d3); // Compute the predicted value. px = Predict(a,b,c); // Correct the prediction. px = CorrectPrediction(ctxt,negative,px); // Compute the error value. errval = x - px; if (negative) errval = -errval; // Quantize the prediction error if NEAR > 0 errval = QuantizePredictionError(errval); // Compute the reconstructed value. rx = Reconstruct(negative,px,errval); // Update so that the next process gets the correct value. UpdateContext(0,rx); // Compute the golomb parameter k from the context. k = GolombParameter(ctxt); // Map the error into a symbol merr = ErrorMapping(errval,ErrorMappingOffset(ctxt,k)); // Golomb-coding of the error. GolombCode(k,merr,m_lLimit); // Update the variables. UpdateState(ctxt,errval); } } while(++lp,--length); EndLine(0); line = line->m_pNext; } while(--lines);
int main(int argc, char **argv) { char *file = NULL; int Do_Start = 1, tmp; int m, p, i, j, n, nchars, theight, twidth, xclick, yclick; int downx = 1000, downy = 1000, upx, upy; long id, winclick; Real xmax, xmin, ymax, ymin, xdiff, ydiff, xgrid_spacing, ygrid_spacing; Real *x, *y, *nls; LineFunction linetype = StartLine; char axis[100], line[256]; FILE *fd; x = (Real *)malloc(1000000 * sizeof(Real)); y = (Real *)malloc(1000000 * sizeof(Real)); nls = (Real *)malloc(1000 * sizeof(Real)); if (x == NULL || y == NULL || nls == NULL) { fprintf(stderr, "Can't allocate initial memory\n"); exit(1); } ymax = xmax = -HUGE_VAL; ymin = xmin = HUGE_VAL; for (i = 1; i < argc; i++) { if (*argv[i] == '-') { if (!strcmp(argv[i], "-nl")) linetype = StartPoint; else if (argv[i][1] == '\0') /* use stdin */ file = argv[i]; else { fprintf(stderr, "Usage:\n\t %s [options] [file]\n\n", argv[0]); fprintf(stderr, "where options include:\n" " -pt plot with points instead of lines\n\n"); fprintf(stderr, "file name `-' specifies stdin\n" "if no file name is specified, " "the default is \"%s\"\n\n", DEFAULT_DATA_FILE); return EXIT_FAILURE; } } else file = argv[i]; } if (file && !strcmp(file, "-")) { fd = stdin; file = "stdin"; } else { if (file == NULL) file = DEFAULT_DATA_FILE; if ((fd = fopen(file, "r")) == NULL) { fprintf(stderr, "%s: can't open file \"%s\"\n", argv[0], file); return EXIT_FAILURE; } } m = 0; p = 0; while (fgets(line, sizeof(line), fd) != NULL) { if (sscanf(line, "%f %f", &x[m], &y[m]) == 2) { if (x[m] > xmax) xmax = x[m]; else if (x[m] < xmin) xmin = x[m]; if (y[m] > ymax) ymax = y[m]; else if (y[m] < ymin) ymin = y[m]; m++; } else { nls[p] = m; p++; } } nls[p++] = m; if (m == 0) return; signal(SIGTERM, nice_end); signal(SIGSTOP, nice_end); signal(SIGTSTP, nice_end); signal(SIGINT, nice_end); signal(SIGQUIT, nice_end); if (!InitializeGraphics(1)) return EXIT_FAILURE; n = 1; do { axis_round(&xmin, &xmax, &xgrid_spacing); axis_round(&ymin, &ymax, &ygrid_spacing); id = CreateWin(0, 0, GRX_SCALE, GRX_SCALE); if (id == 0) { fprintf(stderr, "Help id = 0\n"); return EXIT_FAILURE; } /* Fill the window in black for real eye-catching graphics! */ ForeColor(0); StartFill(id); FillArea(0, 0, GRX_SCALE, GRX_SCALE); Done(); /* draw outline box in white */ ForeColor(7); /* Draw outline box */ StartLine(id); Extend(1000, 1000); Extend(1000, 9000); Extend(9000, 9000); Extend(9000, 1000); Extend(1000, 1000); Done(); /* Draw the data - either lines or dots */ xdiff = 8000 / (xmax - xmin); ydiff = 8000 / (ymax - ymin); for (i = j = 0; j < p; j++) { int n = 0; ForeColor(j % 6 + 1); while (((x[i] < xmin) || (x[i] > xmax) || (y[i] < ymin) || (y[i] > ymax)) && (i < nls[j])) i++; while (i < nls[j]) { if (n == 0) linetype(id); Extend(1000 + (x[i] - xmin) * xdiff, 9000 - (y[i] - ymin) * ydiff); n++; if (n > 450) { Done(); n = 0; continue; } i++; while ((i < nls[j]) && ((x[i] < xmin) || (x[i] > xmax) || (y[i] < ymin) || (y[i] > ymax))) i++; } if (n > 0) Done(); } /* Do axis labels in black */ ForeColor(7); QueryWin(id, &twidth, &theight); PlaceText(id, GRX_SCALE / 2, 0, HCENTER_TEXT | TOP_TEXT, file); PlaceText(id, GRX_SCALE / 2, GRX_SCALE, HCENTER_TEXT | BOTTOM_TEXT, "X"); PlaceText(id, 0, GRX_SCALE / 2, LEFT_TEXT | VCENTER_TEXT, "Y"); sprintf(axis, "%f", ymax); nchars = 1000 / twidth; axis[nchars] = 0; PlaceText(id, GRX_SCALE / 10, GRX_SCALE / 10, RIGHT_TEXT | TOP_TEXT, axis); sprintf(axis, "%f", ymin); axis[nchars] = 0; PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10, RIGHT_TEXT | BOTTOM_TEXT, axis); sprintf(axis, "%f", xmax); PlaceText(id, 9 * GRX_SCALE / 10, 9 * GRX_SCALE / 10, HCENTER_TEXT | TOP_TEXT, axis); sprintf(axis, "%f", xmin); PlaceText(id, GRX_SCALE / 10, 9 * GRX_SCALE / 10, HCENTER_TEXT | TOP_TEXT, axis); fflush(stdout); do { n = WaitForCarriageReturn(&winclick, &xclick, &yclick); switch (n) { case 1: downx = xclick; downy = yclick; break; case 2: upx = xclick; upy = yclick; if (upx < downx) { tmp = downx; downx = upx; upx = tmp; } if (upy < downy) { tmp = downy; downy = upy; upy = tmp; } xmin = (xmax - xmin) * (downx - 1000) / (8000) + xmin; xmax = (xmax - xmin) * (upx - 1000) / (8000) + xmin; ymax = ymax - (ymax - ymin) * (downy - 1000) / (8000); ymin = ymax - (ymax - ymin) * (upy - 1000) / (8000); break; } } while (n && (n != 2)); } while (n); nice_end(EXIT_SUCCESS); return EXIT_SUCCESS; }
static int MacExpand (void* Data) /* If we're currently expanding a macro, set the the scanner token and * attribute to the next value and return true. If we are not expanding * a macro, return false. */ { /* Cast the Data pointer to the actual data structure */ MacExp* Mac = (MacExp*) Data; /* Check if we should abort this macro */ if (DoMacAbort) { /* Reset the flag */ DoMacAbort = 0; /* Abort any open .IF statements in this macro expansion */ CleanupIfStack (Mac->IfSP); /* Terminate macro expansion */ goto MacEnd; } /* We're expanding a macro. Check if we are expanding one of the * macro parameters. */ ExpandParam: if (Mac->ParamExp) { /* Ok, use token from parameter list */ TokSet (Mac->ParamExp); /* Create new line info for this parameter token */ if (Mac->ParamLI) { EndLine (Mac->ParamLI); } Mac->ParamLI = StartLine (&CurTok.Pos, LI_TYPE_MACPARAM, Mac->MacExpansions); /* Set pointer to next token */ Mac->ParamExp = Mac->ParamExp->Next; /* Done */ return 1; } else if (Mac->ParamLI) { /* There's still line info open from the parameter expansion - end it */ EndLine (Mac->ParamLI); Mac->ParamLI = 0; } /* We're not expanding macro parameters. Check if we have tokens left from * the macro itself. */ if (Mac->Exp) { /* Use next macro token */ TokSet (Mac->Exp); /* Create new line info for this token */ if (Mac->LI) { EndLine (Mac->LI); } Mac->LI = StartLine (&CurTok.Pos, LI_TYPE_MACRO, Mac->MacExpansions); /* Set pointer to next token */ Mac->Exp = Mac->Exp->Next; /* Is it a request for actual parameter count? */ if (CurTok.Tok == TOK_PARAMCOUNT) { CurTok.Tok = TOK_INTCON; CurTok.IVal = Mac->ParamCount; return 1; } /* Is it the name of a macro parameter? */ if (CurTok.Tok == TOK_MACPARAM) { /* Start to expand the parameter token list */ Mac->ParamExp = Mac->Params[CurTok.IVal]; /* Go back and expand the parameter */ goto ExpandParam; } /* If it's an identifier, it may in fact be a local symbol */ if ((CurTok.Tok == TOK_IDENT || CurTok.Tok == TOK_LOCAL_IDENT) && Mac->M->LocalCount) { /* Search for the local symbol in the list */ unsigned Index = 0; IdDesc* I = Mac->M->Locals; while (I) { if (SB_Compare (&CurTok.SVal, &I->Id) == 0) { /* This is in fact a local symbol, change the name. Be sure * to generate a local label name if the original name was * a local label, and also generate a name that cannot be * generated by a user. */ if (SB_At (&I->Id, 0) == LocalStart) { /* Must generate a local symbol */ SB_Printf (&CurTok.SVal, "%cLOCAL-MACRO_SYMBOL-%04X", LocalStart, Mac->LocalStart + Index); } else { /* Global symbol */ SB_Printf (&CurTok.SVal, "LOCAL-MACRO_SYMBOL-%04X", Mac->LocalStart + Index); } break; } /* Next symbol */ ++Index; I = I->Next; } /* Done */ return 1; } /* The token was successfully set */ return 1; } /* No more macro tokens. Do we have a final token? */ if (Mac->Final) { /* Set the final token and remove it */ TokSet (Mac->Final); FreeTokNode (Mac->Final); Mac->Final = 0; /* Problem: When a .define style macro is expanded within the call * of a classic one, the latter may be terminated and removed while * the expansion of the .define style macro is still active. Because * line info slots are "stacked", this runs into a CHECK FAILED. For * now, we will fix that by removing the .define style macro expansion * immediately, once the final token is placed. The better solution * would probably be to not require AllocLineInfoSlot/FreeLineInfoSlot * to be called in FIFO order, but this is a bigger change. */ /* End of macro expansion and pop the input function */ FreeMacExp (Mac); PopInput (); /* The token was successfully set */ return 1; } MacEnd: /* End of macro expansion */ FreeMacExp (Mac); /* Pop the input function */ PopInput (); /* No token available */ return 0; }
void scSelection::MoveSelect( eSelectMove moveSelect ) { int setmax = 1; switch ( moveSelect ) { case ePrevChar: case eNextChar: case ePrevCharInPara: case eNextCharInPara: SLCCharacterMove( *this, moveSelect ); break; case ePrevWord: PrevWord( ); break; case eNextWord: NextWord( ); break; case ePrevSpellWord: PrevSpellWord( ); break; case eNextSpellWord: NextSpellWord( ); break; case eStartWord: StartWord( ); break; case eEndWord: EndWord( ); break; case ePrevEntireLine: PrevEntireLine(); break; case eNextEntireLine: NextEntireLine(); break; case ePrevLine: PrevLine(); setmax = 0; break; case eNextLine: NextLine(); setmax = 0; break; case eStartLine: StartLine(); break; case eEndLine: EndLine(); break; case ePrevPara: case eNextPara: case eFirstPara: case eLastPara: Para( moveSelect ); break; case eBeginPara: BeginPara(); break; case eEndPara: EndPara(); break; case ePrevEntireColumn: PrevColumn(); break; case eNextEntireColumn: NextColumn(); break; case eBeginColumn: StartColumn( ); break; case eEndColumn: EndColumn(); break; case eStartStream: fMark.SelectStartStream(); fPoint.SelectStartStream(); break; case eEndStream: fMark.SelectEndStream(); fPoint.SelectEndStream(); break; default: SCDebugBreak(); break; } fMark.UpdateInfo( setmax ); fPoint.UpdateInfo( setmax ); }