void ProcessMonitor::contextMenu(QPoint const& pos) { QTableWidget* table(m_ui.processTable); QTableWidgetItem* item(table->itemAt(pos)); if (!item) return; Process* process(getSelectedProcess(item)); if (!process) return; if (process->status() == Process::Copying) return; QMenu *menu = new QMenu(this); QAction* kill = menu->addAction(tr("Kill Job"), this, SLOT(killProcess())); QAction* remove = menu->addAction(tr("Remove Process"), this, SLOT(removeProcess())); QAction* query = menu->addAction(tr("Query Process"), this, SLOT(queryProcess())); QAction* view = menu->addAction(tr("View Output File"), process, SLOT(viewOutput())); QAction* open = menu->addAction(tr("Visualize Results"), this, SLOT(openOutput())); QAction* copy = menu->addAction(tr("Copy Results From Server"), this, SLOT(copyResults())); kill->setEnabled(false); query->setEnabled(true); remove->setEnabled(false); view->setEnabled(false); open->setEnabled(false); copy->setEnabled(false); Process::Status status(process->status()); if (status == Process::Running || status == Process::Queued || status == Process::Suspended) { kill->setEnabled(true); } if (status != Process::NotRunning && status != Process::Killed && status != Process::Queued) { view->setEnabled(true); } if (status == Process::Killed || status == Process::Error || status == Process::Finished) { remove->setEnabled(true); copy->setEnabled(true); } if (status == Process::Unknown || status == Process::NotRunning) { remove->setEnabled(true); } if (status == Process::Finished && process->jobInfo()->localFilesExist()) { open->setEnabled(true); } menu->exec(table->mapToGlobal(pos)); delete menu; }
int main(int argc, char *argv[]) { if (argc == 1) { cout << "Usage: " << argv[0] << " fileName1 fileName2 ..." << endl; cout << "Please give at least one input file" << endl; return 0; } // open log file if (!openOutput(logFile, logFileName)) { cout << "Log file open error! Exit program" << endl; return 0; } // allocate memory for event db Event *eventDB = new Event[argc - 1]; for (int i = 0; i < argc - 1; i++) { eventDB[i].setInputFile(argv[i+1]); } printOutput(logFile, "Finish all!\n"); // close logFile logFile.close(); return 0; }
PageIterator::PageIterator(string inPath, string outPath, unsigned ioSizeInPages) : inPath(inPath), outPath(outPath), blockSize(ioSizeInPages * PAGE_SIZE), in(inPath), count(0), fpos(0), bpos(0), bytesRead(0), blocksRead(0), prevPageNo(0), asyncBuf(NULL) { openOutput(); buf = new char[ioSizeInPages * PAGE_SIZE]; next(); // first page contains only system metadata }
RiffImportDlg::RiffImportDlg(QWidget *parent) : QDialog(parent), ui(new Ui::RiffImportDlg) { m_riff = new Riff(this); connect(m_riff, SIGNAL(signalInstrument(int, int, QString)), SLOT(slotInstrument(int, int, QString))); connect(m_riff, SIGNAL(signalSoundFont(QString, QString, QString)), SLOT(slotCompleted(QString, QString, QString))); connect(m_riff, SIGNAL(signalDLS(QString, QString, QString)), SLOT(slotCompleted(QString, QString, QString))); ui->setupUi(this); connect(ui->m_inputBtn, SIGNAL(clicked()), SLOT(openInput())); connect(ui->m_outputBtn, SIGNAL(clicked()), SLOT(openOutput())); }
/** @brief Subscribe to capture sound from the opened input device. If the input device is not open, it will be opened before capturing. */ void Audio::subscribeInput() { qDebug() << "subscribing input" << inputSubscriptions; if (!inputSubscriptions++) { openInput(Settings::getInstance().getInDev()); openOutput(Settings::getInstance().getOutDev()); #if (!FIX_SND_PCM_PREPARE_BUG) if (alInDev) { qDebug() << "starting capture"; alcCaptureStart(alInDev); } #endif } }
void startRec() { if(RecFlag == 0) { setWindow(window,"mohnish/gb-drum-kit record1.jpg"); printf("%d-Tempo \n",Tempo); setTempo(Tempo); setTime(4,4); openOutput(SongName,0,0); RecFlag = 1; PlayFlag = 1; } else { closeOutput(); setWindow(window,"mohnish/gb-drum-kit changed1.jpg"); RecFlag = 0; } }
/** Play a 44100Hz mono 16bit PCM sound */ void Audio::playMono16Sound(const QByteArray& data) { QMutexLocker lock(&audioOutLock); if (!alOutDev) { if (!openOutput(Settings::getInstance().getOutDev())) return; } ALuint buffer; alGenBuffers(1, &buffer); alBufferData(buffer, AL_FORMAT_MONO16, data.data(), data.size(), 44100); alSourcef(alMainSource, AL_GAIN, outputVolume); alSourcei(alMainSource, AL_BUFFER, buffer); alSourcePlay(alMainSource); ALint sizeInBytes; ALint channels; ALint bits; alGetBufferi(buffer, AL_SIZE, &sizeInBytes); alGetBufferi(buffer, AL_CHANNELS, &channels); alGetBufferi(buffer, AL_BITS, &bits); int lengthInSamples = sizeInBytes * 8 / (channels * bits); ALint frequency; alGetBufferi(buffer, AL_FREQUENCY, &frequency); qreal duration = (lengthInSamples / static_cast<qreal>(frequency)) * 1000; int remaining = timer->interval(); if (duration > remaining) timer->start(duration); alDeleteBuffers(1, &buffer); }
int main (int argc, char **argv) { AFfilehandle file; AudioUnit outputUnit; if (argc < 2) { fprintf(stderr, "usage: %s filename\n", argv[0]); exit(EXIT_FAILURE); } file = afOpenFile(argv[1], "r", AF_NULL_FILESETUP); if (file == AF_NULL_FILEHANDLE) { fprintf(stderr, "Could not open file '%s' for reading.\n", argv[1]); exit(EXIT_FAILURE); } openOutput(&outputUnit); setupOutput(&outputUnit, file); AudioOutputUnitStart(outputUnit); buffer = malloc(BUFFER_FRAME_COUNT * afGetVirtualFrameSize(file, AF_DEFAULT_TRACK, 1)); while (isPlaying) usleep(250000); AudioOutputUnitStop(outputUnit); AudioUnitUninitialize(outputUnit); CloseComponent(outputUnit); free(buffer); afCloseFile(file); }
int main (int argc, char *argv[]) { int i = 0; /* index & counter */ char line[MAXCHAR + 1] = ""; /* working line buffer */ char previousLine [MAXCHAR + 1] = ""; /* previous line buffer */ char author[MAXNAME + 1] = ""; /* author of the comments name */ int page = 0; /* page number */ FILE *filein = NULL; /* input file (author's comments) */ FILE *fileout = NULL; /* current output file (one comment) */ LINE_ANALYSIS_RESULT status = START_COMMENT; /* result of line analysis */ /* * check input parameter */ if (argc != 2) { printf("Usage: splitIntoSingleComments <input_file>\n"); exit(-1); } else { printf("-->Processing: %s\n", argv[1]); } /* * open input file */ filein = fopen(argv[1], "r"); /* * extract from input file name (<author>.comments) the <author> field. * REMARK: the first encountered dot '.' is used as separator. */ strcpy(author, argv[1]); i = 0; while (author[i] != '.') { i++; } author[i] = '\0'; /* * open the first output file (000): it will contains everything between the * beginning of the file and the first comment. */ fileout = openOutput(page, author); /* * process all lines in the input file */ while (getLine(filein, line) != EOF ) { status = treatLine(line, previousLine, &page); switch (status) { case START_COMMENT: /* * - close current output * - open a new output file (<ppp>-<author>.tmp_single_comments) * - write the sepaartor line (80 "-") * - copy the line into current output file */ if ( previousLine[0] != '\0') fprintf(fileout, "\n"); closeOutput(fileout, previousLine); fileout = openOutput(page, author); fprintf(fileout, "%s\n", line); break; case COPY: /* * - copy the line into current output file */ fprintf(fileout, "%s\n", line); fflush(fileout); break; case SKIP: /* * - skip the line */ break; default: /* * PANIC ERROR */ printf("PANIC ERROR treatLine return status unknown: %d\n", status); exit(-1); break; } strcpy(previousLine, line); } closeOutput(fileout, previousLine); fclose(filein); exit(0); }
int main (int argc, char **argv) { unsigned char *buf; long bufSize = 0; unsigned char *original; long originalSize = 0; unsigned char *originalGray = NULL; long originalGraySize = 0; unsigned char *compressed = NULL; unsigned long compressedSize = 0; unsigned char *compressedGray; long compressedGraySize = 0; unsigned char *tmpImage; int width, height; unsigned char *metaBuf; unsigned int metaSize = 0; FILE *file; // Parse commandline options command_t cmd; command_init(&cmd, argv[0], VERSION); cmd.usage = "[options] input.jpg compressed-output.jpg"; command_option(&cmd, "-t", "--target [arg]", "Set target quality [0.9999]", setTarget); command_option(&cmd, "-q", "--quality [arg]", "Set a quality preset: low, medium, high, veryhigh [medium]", setQuality); command_option(&cmd, "-n", "--min [arg]", "Minimum JPEG quality [40]", setMinimum); command_option(&cmd, "-x", "--max [arg]", "Maximum JPEG quality [95]", setMaximum); command_option(&cmd, "-l", "--loops [arg]", "Set the number of runs to attempt [6]", setAttempts); command_option(&cmd, "-a", "--accurate", "Favor accuracy over speed", setAccurate); command_option(&cmd, "-m", "--method [arg]", "Set comparison method to one of 'mpe', 'ssim', 'ms-ssim', 'smallfry' [ssim]", setMethod); command_option(&cmd, "-s", "--strip", "Strip metadata", setStrip); command_option(&cmd, "-d", "--defish [arg]", "Set defish strength [0.0]", setDefish); command_option(&cmd, "-z", "--zoom [arg]", "Set defish zoom [1.0]", setZoom); command_option(&cmd, "-r", "--ppm", "Parse input as PPM instead of JPEG", setPpm); command_option(&cmd, "-c", "--no-copy", "Disable copying files that will not be compressed", setCopyFiles); command_option(&cmd, "-p", "--no-progressive", "Disable progressive encoding", setNoProgressive); command_parse(&cmd, argc, argv); if (cmd.argc < 2) { command_help(&cmd); return 255; } if (method == UNKNOWN) { fprintf(stderr, "Invalid method!"); command_help(&cmd); return 255; } // No target passed, use preset! if (!target) { setTargetFromPreset(); } // Read original bufSize = readFile((char *) cmd.argv[0], (void **) &buf); if (!bufSize) { return 1; } if (!ppm) { // Decode the JPEG originalSize = decodeJpeg(buf, bufSize, &original, &width, &height, JCS_RGB); } else { // Decode the PPM originalSize = decodePpm(buf, bufSize, &original, &width, &height); } if (defishStrength) { fprintf(stderr, "Defishing...\n"); tmpImage = malloc(width * height * 3); defish(original, tmpImage, width, height, 3, defishStrength, defishZoom); free(original); original = tmpImage; } // Convert RGB input into Y originalGraySize = grayscale(original, &originalGray, width, height); if (!ppm) { // Read metadata (EXIF / IPTC / XMP tags) if (getMetadata(buf, bufSize, &metaBuf, &metaSize, COMMENT)) { fprintf(stderr, "File already processed by jpeg-recompress!\n"); if (copyFiles) { file = openOutput(cmd.argv[1]); fwrite(buf, bufSize, 1, file); fclose(file); free(buf); return 0; } else { free(buf); return 2; } } } if (strip) { // Pretend we have no metadata metaSize = 0; } else { fprintf(stderr, "Metadata size is %ukb\n", metaSize / 1024); } if (!originalSize || !originalGraySize) { return 1; } // Do a binary search to find the optimal encoding quality for the // given target SSIM value. int min = jpegMin, max = jpegMax; for (int attempt = attempts - 1; attempt >= 0; --attempt) { float metric; int quality = min + (max - min) / 2; int progressive = attempt ? 0 : !noProgressive; int optimize = accurate ? 1 : (attempt ? 0 : 1); // Recompress to a new quality level, without optimizations (for speed) compressedSize = encodeJpeg(&compressed, original, width, height, JCS_RGB, quality, progressive, optimize); // Load compressed luma for quality comparison compressedGraySize = decodeJpeg(compressed, compressedSize, &compressedGray, &width, &height, JCS_GRAYSCALE); if (!compressedGraySize) { fprintf(stderr, "Unable to decode file that was just encoded!\n"); return 1; } if (!attempt) { fprintf(stderr, "Final optimized "); } // Measure quality difference switch (method) { case MS_SSIM: metric = iqa_ms_ssim(originalGray, compressedGray, width, height, width, 0); fprintf(stderr, "ms-ssim"); break; case SMALLFRY: metric = smallfry_metric(originalGray, compressedGray, width, height); fprintf(stderr, "smallfry"); break; case MPE: metric = meanPixelError(originalGray, compressedGray, width, height, 1); fprintf(stderr, "mpe"); break; case SSIM: default: metric = iqa_ssim(originalGray, compressedGray, width, height, width, 0, 0); fprintf(stderr, "ssim"); break; } if (attempt) { fprintf(stderr, " at q=%i (%i - %i): %f\n", quality, min, max, metric); } else { fprintf(stderr, " at q=%i: %f\n", quality, metric); } if (metric < target) { if (compressedSize >= bufSize) { fprintf(stderr, "Output file would be larger than input!\n"); free(compressed); free(compressedGray); if (copyFiles) { file = openOutput(cmd.argv[1]); fwrite(buf, bufSize, 1, file); fclose(file); free(buf); return 0; } else { free(buf); return 1; } } switch (method) { case SSIM: case MS_SSIM: case SMALLFRY: // Too distorted, increase quality min = quality + 1; break; case MPE: // Higher than required, decrease quality max = quality - 1; break; } } else { switch (method) { case SSIM: case MS_SSIM: case SMALLFRY: // Higher than required, decrease quality max = quality - 1; break; case MPE: // Too distorted, increase quality min = quality + 1; break; } } // If we aren't done yet, then free the image data if (attempt) { free(compressed); free(compressedGray); } } free(buf); // Calculate and show savings, if any int percent = (compressedSize + metaSize) * 100 / bufSize; unsigned long saved = (bufSize > compressedSize) ? bufSize - compressedSize - metaSize : 0; fprintf(stderr, "New size is %i%% of original (saved %lu kb)\n", percent, saved / 1024); if (compressedSize >= bufSize) { fprintf(stderr, "Output file is larger than input, aborting!\n"); return 1; } // Open output file for writing file = openOutput(cmd.argv[1]); // Write output fwrite(compressed, 20, 1, file); /* 0xffd8 and JFIF marker */ // Write comment so we know not to reprocess this file // in the future if it gets passed in again. // 0xfffe (COM marker), two-byte big-endian length, string fputc(0xff, file); fputc(0xfe, file); fputc(0x00, file); fputc(32, file); fwrite(COMMENT, 30, 1, file); // Write metadata markers if (!strip && !ppm) { fwrite(metaBuf, metaSize, 1, file); } // Write image data fwrite(compressed + 20, compressedSize - 20, 1, file); fclose(file); // Cleanup command_free(&cmd); if (!strip && !ppm) { free(metaBuf); } free(compressed); free(original); free(originalGray); return 0; }
/*=export_func optionParseShell * private: * * what: Decipher a boolean value * arg: + tOptions* + pOpts + program options descriptor + * * doc: * Emit a shell script that will parse the command line options. =*/ void optionParseShell( tOptions* pOpts ) { /* * Check for our SHELL option now. * IF the output file contains the "#!" magic marker, * it will override anything we do here. */ if (HAVE_OPT( SHELL )) pzShell = OPT_ARG( SHELL ); else if (! ENABLED_OPT( SHELL )) pzShell = NULL; else if ((pzShell = getenv( "SHELL" )), pzShell == NULL) pzShell = "/bin/sh"; /* * Check for a specified output file */ if (HAVE_OPT( SCRIPT )) openOutput( OPT_ARG( SCRIPT )); emitUsage( pOpts ); emitSetup( pOpts ); /* * There are four modes of option processing. */ switch (pOpts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) { case OPTPROC_LONGOPT: fputs( zLoopCase, stdout ); fputs( zLongSelection, stdout ); fputs( zLongOptInit, stdout ); emitLong( pOpts ); printf( zLongOptArg, pOpts->pzPROGNAME ); fputs( zEndSelection, stdout ); fputs( zNoSelection, stdout ); break; case 0: fputs( zLoopOnly, stdout ); fputs( zLongOptInit, stdout ); emitLong( pOpts ); printf( zLongOptArg, pOpts->pzPROGNAME ); break; case OPTPROC_SHORTOPT: fputs( zLoopCase, stdout ); fputs( zFlagSelection, stdout ); fputs( zFlagOptInit, stdout ); emitFlag( pOpts ); printf( zFlagOptArg, pOpts->pzPROGNAME ); fputs( zEndSelection, stdout ); fputs( zNoSelection, stdout ); break; case OPTPROC_LONGOPT|OPTPROC_SHORTOPT: fputs( zLoopCase, stdout ); fputs( zLongSelection, stdout ); fputs( zLongOptInit, stdout ); emitLong( pOpts ); printf( zLongOptArg, pOpts->pzPROGNAME ); fputs( zEndSelection, stdout ); fputs( zFlagSelection, stdout ); fputs( zFlagOptInit, stdout ); emitFlag( pOpts ); printf( zFlagOptArg, pOpts->pzPROGNAME ); fputs( zEndSelection, stdout ); fputs( zNoSelection, stdout ); break; } printf( zLoopEnd, pOpts->pzPROGNAME, zTrailerMarker ); if ((pzTrailer != NULL) && (*pzTrailer != '\0')) fputs( pzTrailer, stdout ); else if (ENABLED_OPT( SHELL )) printf( "\nenv | grep '^%s_'\n", pOpts->pzPROGNAME ); fflush( stdout ); fchmod( STDOUT_FILENO, 0755 ); fclose( stdout ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , m_ui(new Ui::MainWindow) , m_inst(0) , m_aspect(-1) , m_preview(0) , m_previewDock(0) , m_posBoxLock(false) , m_accelBoxLock(false) , m_pos(0) , m_setPosLock(false) { static_mainWindow = this; m_ui->setupUi(this); setWindowTitle("Teleprompter - DViz"); setWindowIcon(QIcon(":/data/icon-d.png")); connect(m_ui->actionOpen_Text_File, SIGNAL(triggered()), this, SLOT(slotOpen())); connect(m_ui->actionSave, SIGNAL(triggered()), this, SLOT(slotSave())); connect(m_ui->actionSave_As, SIGNAL(triggered()), this, SLOT(slotSaveAs())); connect(m_ui->actionSetup_Outputs, SIGNAL(triggered()), this, SLOT(slotOutputSetup())); connect(m_ui->actionExit, SIGNAL(triggered()), this, SLOT(slotExit())); m_ui->playBtn->setIcon(QIcon(":/data/action-play.png")); connect(m_ui->playBtn, SIGNAL(clicked()), this, SLOT(slotTogglePlay())); connect(m_ui->posBox, SIGNAL(valueChanged(int)), this, SLOT(slotPosBoxChanged(int))); connect(m_ui->accelBox, SIGNAL(valueChanged(int)), this, SLOT(slotAccelBoxChanged(int))); connect(m_ui->accelResetBtn, SIGNAL(clicked()), this, SLOT(slotResetAccel())); m_ui->accelResetBtn->setIcon(QIcon(":/data/stock-undo.png")); m_ui->accelResetBtn->setToolTip("Reset to Normal Speed (CTRL+SHIFT+Z)"); m_ui->accelResetBtn->setShortcut(QString(tr("CTRL+SHIFT+Z"))); connect(&m_animTimer, SIGNAL(timeout()), this, SLOT(animate())); m_animTimer.setInterval(ANIMATE_BASE_MS); m_editor = new RichTextEditorWidget(m_ui->mainWidget); QLayoutItem * firstItem = m_ui->mainWidget->layout()->takeAt(0); m_ui->mainWidget->layout()->addWidget(m_editor); m_ui->mainWidget->layout()->addItem(firstItem); connect(m_editor, SIGNAL(contentsChanged()), this, SLOT(slotTextChanged())); m_ui->actionSetup_Outputs->setIcon(QIcon(":data/stock-preferences.png")); QSettings s; bool flag = s.value("teleprompter/firstrun",true).toBool(); if(flag) { s.setValue("teleprompter/firstrun",false); slotOutputSetup(); } AppSettings::setGridEnabled(false); Output * output = AppSettings::outputs().first(); m_previewDock = new QDockWidget(QString(tr("%1 Preiew")).arg(output->name()), this); m_previewDock->setObjectName(output->name()); m_preview = new OutputViewer(0,m_previewDock); m_previewDock->setWidget(m_preview); addDockWidget(Qt::BottomDockWidgetArea, m_previewDock); m_group = new SlideGroup(); m_group->setGroupTitle("Group"); //AbstractItem::guessTitle(QFileInfo(fileName).baseName())); m_slide = new Slide(); m_textbox = new TextBoxItem(); m_textbox->setItemId(ItemFactory::nextId()); m_textbox->setItemName(QString("TextBoxItem%1").arg(m_textbox->itemId())); AbstractVisualItem * bg = dynamic_cast<AbstractVisualItem*>(m_slide->background()); // qDebug() << "Slide "<<slideNum<<": [\n"<<tmpList.join("\n")<<"\n]";; bg->setFillType(AbstractVisualItem::Solid); bg->setFillBrush(Qt::black); // Outline pen for the text QPen pen = QPen(Qt::black,1.5); pen.setJoinStyle(Qt::MiterJoin); m_textbox->setPos(QPointF(0,0)); m_textbox->setOutlinePen(pen); m_textbox->setOutlineEnabled(true); m_textbox->setFillBrush(Qt::white); m_textbox->setFillType(AbstractVisualItem::Solid); m_textbox->setShadowEnabled(false); // m_textbox->setShadowBrush(Qt::red); // m_textbox->setShadowBlurRadius(3); m_slide->addItem(m_textbox); m_slide->setSlideNumber(0); m_group->addSlide(m_slide); openOutput(); m_inst->setSlideGroup(m_group); openTextFile("test.txt"); }