VaApi::VaApi() { init = true; auto xdpy = QX11Info::display(); VADisplay display = m_display = vaGetDisplayGLX(xdpy); if (!check(display ? VA_STATUS_SUCCESS : VA_STATUS_ERROR_UNIMPLEMENTED, "Cannot create VADisplay.")) return; int major, minor; if (!check(vaInitialize(m_display, &major, &minor), "Cannot initialize VA-API.")) return; auto size = vaMaxNumProfiles(display); m_profiles.resize(size); if (!check(vaQueryConfigProfiles(display, m_profiles.data(), &size), "No available profiles.")) return; m_profiles.resize(size); for (auto profile : m_profiles) { int size = vaMaxNumEntrypoints(display); QVector<VAEntrypoint> entries(size); if (!isSuccess(vaQueryConfigEntrypoints(display, profile, entries.data(), &size))) continue; entries.resize(size); m_entries.insert(profile, entries); } initCodecs(); #ifdef USE_VAVPP initFilters(); #endif _Debug("VA-API is initialized."); ok = true; }
void WorkflowRenderer::startPreview() { if ( m_mainWorkflow->getLengthFrame() <= 0 ) return ; if ( paramsHasChanged( m_width, m_height, m_outputFps, m_aspectRatio ) == true ) { m_width = width(); m_height = height(); m_outputFps = outputFps(); m_aspectRatio = aspectRatio(); } initFilters(); setupRenderer( m_width, m_height, m_outputFps ); m_mainWorkflow->setFullSpeedRender( false ); m_mainWorkflow->startRender( m_width, m_height, m_outputFps ); m_isRendering = true; m_paused = false; m_stopping = false; m_pts = 0; m_audioPts = 0; m_sourceRenderer->start(); }
void AudioInput::updateBands(int nb){ delete[] fftBands; delete[] fftBandsTemp; nBands = nb; fftBands = new float[nBands]; fftBandsTemp = new float[nBands]; powerN = log10((double)nfftResult)/nBands; memset(fftBands, 0, nBands*sizeof(float)); memset(fftBandsTemp, 0, nBands*sizeof(float)); if (audiobars != NULL) delete[] audiobars; if (temp_bars != NULL) { delete[] temp_bars; /*for (int i=0; i<nof_bands; i++) { delete bp_filter[i]; }*/ //free(bp_filter); delete[] bp_filter; } initFilters(nBands); }
/** * @brief FilterWidget::FilterWidget * @param parent */ FilterWidget::FilterWidget(QWidget *parent) : QWidget(parent), ui(new Ui::FilterWidget) { ui->setupUi(this); ui->lineEdit->setShowMagnifier(true); ui->lineEdit->addAdditionalStyleSheet("QLineEdit { border: 1px solid rgba(0, 0, 0, 100); border-radius: 10px; }"); ui->lineEdit->setType(MyLineEdit::TypeClear); ui->lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); m_list = new QListWidget(); m_list->setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint)); m_list->setAttribute(Qt::WA_ShowWithoutActivating); m_activeWidget = WidgetMovies; QPalette palette = m_list->palette(); palette.setColor(QPalette::Highlight, palette.color(QPalette::Highlight)); palette.setColor(QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); m_list->setPalette(palette); m_list->setStyleSheet(QString("background-color: transparent; border: 1px solid rgba(255, 255, 255, 200); border-radius: 5px;")); m_list->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(onFilterTextChanged(QString))); connect(ui->lineEdit, SIGNAL(keyDown()), this, SLOT(onKeyDown())); connect(ui->lineEdit, SIGNAL(keyUp()), this, SLOT(onKeyUp())); connect(ui->lineEdit, SIGNAL(focusOut()), m_list, SLOT(hide())); connect(ui->lineEdit, SIGNAL(focusIn()), this, SLOT(setupFilters())); connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(addSelectedFilter())); connect(ui->lineEdit, SIGNAL(backspaceInFront()), this, SLOT(removeLastFilter())); connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(addFilterFromItem(QListWidgetItem*))); initFilters(); }
/* * Setup filterbank internals */ bool ChannelizerBase::init() { int i; /* * Filterbank coefficients, fft plan, history, and output sample * rate conversion blocks */ if (!initFilters()) { LOG(ERR) << "Failed to initialize channelizing filter"; return false; } mResampler = new Resampler(mP, mQ, mFiltLen, mChanM); if (!mResampler->init()) { LOG(ERR) << "Failed to initialize resampling filter"; return false; } history = (struct cxvec **) malloc(sizeof(struct cxvec *) * mChanM); for (i = 0; i < mChanM; i++) { history[i] = cxvec_alloc(mFiltLen, 0, NULL, 0); cxvec_reset(history[i]); } if (!initFFT()) { LOG(ERR) << "Failed to initialize FFT"; return false; } mapBuffers(); return true; }
void VideoClipWorkflow::initializeVlcOutput() { preallocate(); m_vlcMedia->addOption(":no-audio"); m_vlcMedia->addOption(":no-sout-audio"); initFilters(); }
void TMultDispFrame::setContest( BaseContestLog *pct ) { ct = pct; StatsDispFrame->setContest( ct ); initFilters(); reInitialiseCountries(); reInitialiseDistricts(); reInitialiseLocators(); reInitialiseStats(); }
MainTabOrderItemController::MainTabOrderItemController() { view = new MainTabOrderItem(this); documentTVModel = new OrderDocumentTVModel(); orderService = new OrderService(); initModel(); initFilters(); initSelectingColumnVisibility(); restoreTableState(); }
void VideoClipWorkflow::initializeInternals() { initFilters(); m_renderer->setName( qPrintable( QString("VideoClipWorkflow " % m_clipHelper->uuid().toString() ) ) ); m_renderer->enableVideoOutputToMemory( this, &lock, &unlock, m_fullSpeedRender ); m_renderer->setOutputWidth( m_width ); m_renderer->setOutputHeight( m_height ); m_renderer->setOutputFps( (float)VLMC_PROJECT_GET_DOUBLE( "video/VLMCOutputFPS" ) ); m_renderer->setOutputVideoCodec( "RV32" ); }
MainTabSaleItemController::MainTabSaleItemController() { view = new MainTabSaleItem(this); invoiceService = new InvoiceService(); fkService = new DocumentFKService(); zalService = new DocumentZALService(); initModel(); initFilters(); initSelectingColumnVisibility(); restoreTableState(); }
//---------------------------------------------------------------------------- AudioInput::AudioInput(float sRate, int bufferSize, int iNBands, float fResponse, int iAmpScale, int iFreqScale, int iResampling, float fXScale, float fYScale, AudioEffect* effect): effect(effect),level(0.0f),sampleRate(sRate),bufferSize(bufferSize),nBands(iNBands),halfLife(fResponse), curFftScaling(iAmpScale),curFreqScaling(iFreqScale),curResampling(iResampling),xScale(fXScale), yScale(fYScale),maxFreq(0),maxMagni(0) //AudioInput::AudioInput(float sRate, int bufferSize, int iNBands, float fResponse, int iAmpScale): //level(0.0f),sampleRate(sRate),bufferSize(bufferSize),nBands(iNBands),halfLife(fResponse),curFftScaling(iAmpScale),maxFreq(0),maxMagni(0) { cursor = 0; buffer = new float[bufferSize]; memset(buffer, 0, bufferSize*sizeof(float)); magnitude = NULL; audiobars = NULL; temp_bars = NULL; gain = 1/32768.0; nSamples = bufferSize; nfftResult = (int)(nSamples*0.5+1); fftin = new float[nSamples]; memset(fftin, 0, nSamples*sizeof(float)); fftout = (fftwf_complex*) fftwf_malloc(sizeof(fftwf_complex) * nSamples); plan = fftwf_plan_dft_r2c_1d(nSamples, fftin, fftout, FFTW_MEASURE); fftMag = new float[nfftResult]; memset(fftMag, 0, nfftResult*sizeof(float)); fftBands = new float[nBands]; memset(fftBands, 0, nBands*sizeof(float)); fftBandsTemp = new float[nBands]; memset(fftBandsTemp, 0, nBands*sizeof(float)); powerN = log10((double)nfftResult)/nBands; curResponse = 0.90f; lock = false; initFilters(nBands); }
// Betaflight pid controller, which will be maintained in the future with additional features specialised for current (mini) multirotor usage. // Based on 2DOF reference design (matlab) void pidBetaflight(const pidProfile_t *pidProfile, uint16_t max_angle_inclination, const rollAndPitchTrims_t *angleTrim, const rxConfig_t *rxConfig) { float errorRate = 0, rP = 0, rD = 0, PVRate = 0; float ITerm,PTerm,DTerm; static float lastRateError[2]; static float Kp[3], Ki[3], Kd[3], b[3], c[3], rollPitchMaxVelocity, yawMaxVelocity, previousSetpoint[3]; float delta; int axis; float horizonLevelStrength = 1; float tpaFactor = PIDweight[0] / 100.0f; // tpa is now float initFilters(pidProfile); if (FLIGHT_MODE(HORIZON_MODE)) { // Figure out the raw stick positions const int32_t stickPosAil = ABS(getRcStickDeflection(FD_ROLL, rxConfig->midrc)); const int32_t stickPosEle = ABS(getRcStickDeflection(FD_PITCH, rxConfig->midrc)); const int32_t mostDeflectedPos = MAX(stickPosAil, stickPosEle); // Progressively turn off the horizon self level strength as the stick is banged over horizonLevelStrength = (float)(500 - mostDeflectedPos) / 500; // 1 at centre stick, 0 = max stick deflection if(pidProfile->D8[PIDLEVEL] == 0){ horizonLevelStrength = 0; } else { horizonLevelStrength = constrainf(((horizonLevelStrength - 1) * (100 / pidProfile->D8[PIDLEVEL])) + 1, 0, 1); } } // Yet Highly experimental and under test and development // Throttle coupled to Igain like inverted TPA // 50hz calculation (should cover all rx protocols) static float kiThrottleGain = 1.0f; if (pidProfile->itermThrottleGain) { const uint16_t maxLoopCount = 20000 / targetPidLooptime; const float throttleItermGain = (float)pidProfile->itermThrottleGain * 0.001f; static int16_t previousThrottle; static uint16_t loopIncrement; if (loopIncrement >= maxLoopCount) { kiThrottleGain = 1.0f + constrainf((float)(ABS(rcCommand[THROTTLE] - previousThrottle)) * throttleItermGain, 0.0f, 5.0f); // Limit to factor 5 previousThrottle = rcCommand[THROTTLE]; loopIncrement = 0; } else { loopIncrement++; } } // ----------PID controller---------- for (axis = 0; axis < 3; axis++) { static uint8_t configP[3], configI[3], configD[3]; // Prevent unnecessary computing and check for changed PIDs. No need for individual checks. Only pids is fine for now // Prepare all parameters for PID controller if ((pidProfile->P8[axis] != configP[axis]) || (pidProfile->I8[axis] != configI[axis]) || (pidProfile->D8[axis] != configD[axis])) { Kp[axis] = PTERM_SCALE * pidProfile->P8[axis]; Ki[axis] = ITERM_SCALE * pidProfile->I8[axis]; Kd[axis] = DTERM_SCALE * pidProfile->D8[axis]; b[axis] = pidProfile->ptermSetpointWeight / 100.0f; c[axis] = pidProfile->dtermSetpointWeight / 100.0f; yawMaxVelocity = pidProfile->yawRateAccelLimit * 1000 * getdT(); rollPitchMaxVelocity = pidProfile->rateAccelLimit * 1000 * getdT(); configP[axis] = pidProfile->P8[axis]; configI[axis] = pidProfile->I8[axis]; configD[axis] = pidProfile->D8[axis]; } // Limit abrupt yaw inputs / stops float maxVelocity = (axis == YAW) ? yawMaxVelocity : rollPitchMaxVelocity; if (maxVelocity) { float currentVelocity = setpointRate[axis] - previousSetpoint[axis]; if (ABS(currentVelocity) > maxVelocity) { setpointRate[axis] = (currentVelocity > 0) ? previousSetpoint[axis] + maxVelocity : previousSetpoint[axis] - maxVelocity; } previousSetpoint[axis] = setpointRate[axis]; } // Yaw control is GYRO based, direct sticks control is applied to rate PID if ((FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE)) && axis != YAW) { // calculate error angle and limit the angle to the max inclination #ifdef GPS const float errorAngle = (constrain(2 * rcCommand[axis] + GPS_angle[axis], -((int) max_angle_inclination), +max_angle_inclination) - attitude.raw[axis] + angleTrim->raw[axis]) / 10.0f; // 16 bits is ok here #else const float errorAngle = (constrain(2 * rcCommand[axis], -((int) max_angle_inclination), +max_angle_inclination) - attitude.raw[axis] + angleTrim->raw[axis]) / 10.0f; // 16 bits is ok here #endif if (FLIGHT_MODE(ANGLE_MODE)) { // ANGLE mode - control is angle based, so control loop is needed setpointRate[axis] = errorAngle * pidProfile->P8[PIDLEVEL] / 10.0f; } else { // HORIZON mode - direct sticks control is applied to rate PID // mix up angle error to desired AngleRate to add a little auto-level feel setpointRate[axis] = setpointRate[axis] + (errorAngle * pidProfile->I8[PIDLEVEL] * horizonLevelStrength / 10.0f); } } PVRate = gyroADCf[axis] / 16.4f; // Process variable from gyro output in deg/sec // --------low-level gyro-based PID based on 2DOF PID controller. ---------- // ---------- 2-DOF PID controller with optional filter on derivative term. b = 1 and only c can be tuned (amount derivative on measurement or error). ---------- // Used in stand-alone mode for ACRO, controlled by higher level regulators in other modes // ----- calculate error / angle rates ---------- errorRate = setpointRate[axis] - PVRate; // r - y rP = b[axis] * setpointRate[axis] - PVRate; // br - y // Slowly restore original setpoint with more stick input float diffRate = errorRate - rP; rP += diffRate * rcInput[axis]; // Reduce Hunting effect and jittering near setpoint. Limit multiple zero crossing within deadband and lower PID affect during low error amount float dynReduction = tpaFactor; if (pidProfile->toleranceBand) { const float minReduction = (float)pidProfile->toleranceBandReduction / 100.0f; static uint8_t zeroCrossCount[3]; static uint8_t currentErrorPolarity[3]; if (ABS(errorRate) < pidProfile->toleranceBand) { if (zeroCrossCount[axis]) { if (currentErrorPolarity[axis] == POSITIVE_ERROR) { if (errorRate < 0 ) { zeroCrossCount[axis]--; currentErrorPolarity[axis] = NEGATIVE_ERROR; } } else { if (errorRate > 0 ) { zeroCrossCount[axis]--; currentErrorPolarity[axis] = POSITIVE_ERROR; } } } else { dynReduction *= constrainf(ABS(errorRate) / pidProfile->toleranceBand, minReduction, 1.0f); } } else { zeroCrossCount[axis] = pidProfile->zeroCrossAllowanceCount; currentErrorPolarity[axis] = (errorRate > 0) ? POSITIVE_ERROR : NEGATIVE_ERROR; } } // -----calculate P component PTerm = Kp[axis] * rP * dynReduction; // -----calculate I component. // Reduce strong Iterm accumulation during higher stick inputs float accumulationThreshold = (axis == YAW) ? pidProfile->yawItermIgnoreRate : pidProfile->rollPitchItermIgnoreRate; float setpointRateScaler = constrainf(1.0f - (1.5f * (ABS(setpointRate[axis]) / accumulationThreshold)), 0.0f, 1.0f); // Handle All windup Scenarios // limit maximum integrator value to prevent WindUp float itermScaler = setpointRateScaler * kiThrottleGain; errorGyroIf[axis] = constrainf(errorGyroIf[axis] + Ki[axis] * errorRate * getdT() * itermScaler, -250.0f, 250.0f); // I coefficient (I8) moved before integration to make limiting independent from PID settings ITerm = errorGyroIf[axis]; //-----calculate D-term (Yaw D not yet supported) if (axis == YAW) { if (pidProfile->yaw_lpf_hz) PTerm = pt1FilterApply4(&yawFilter, PTerm, pidProfile->yaw_lpf_hz, getdT()); axisPID[axis] = lrintf(PTerm + ITerm); DTerm = 0.0f; // needed for blackbox } else { rD = c[axis] * setpointRate[axis] - PVRate; // cr - y delta = rD - lastRateError[axis]; lastRateError[axis] = rD; // Divide delta by targetLooptime to get differential (ie dr/dt) delta *= (1.0f / getdT()); if (debugMode == DEBUG_DTERM_FILTER) debug[axis] = Kd[axis] * delta * dynReduction; // Filter delta if (dtermNotchInitialised) delta = biquadFilterApply(&dtermFilterNotch[axis], delta); if (pidProfile->dterm_lpf_hz) { if (dtermBiquadLpfInitialised) { delta = biquadFilterApply(&dtermFilterLpf[axis], delta); } else { delta = pt1FilterApply4(&deltaFilter[axis], delta, pidProfile->dterm_lpf_hz, getdT()); } } DTerm = Kd[axis] * delta * dynReduction; // -----calculate total PID output axisPID[axis] = constrain(lrintf(PTerm + ITerm + DTerm), -900, 900); } // Disable PID control at zero throttle if (!pidStabilisationEnabled) axisPID[axis] = 0; #ifdef GTUNE if (FLIGHT_MODE(GTUNE_MODE) && ARMING_FLAG(ARMED)) { calculate_Gtune(axis); } #endif #ifdef BLACKBOX axisPID_P[axis] = PTerm; axisPID_I[axis] = ITerm; axisPID_D[axis] = DTerm; #endif } }
Utility::FilterApplier::FilterApplier(Model::FilterList& list, int width, int height, int pixelFormat):width_(width),height_(height),pixelFormat_(pixelFormat),list_(&list), isRunning_(false) { createFilterString(); initFilters(); }
void TempController::updateState(void){ RawTemperature estimatedOvershoot; RawTemperature estimatedPeakTemperature; //update state switch(state){ case STARTUP: if (tempSensorMgr.ready()) { initFilters(); fridgeTemperatureSetting = mainSettings.setpoint; state = IDLE; } else { return; } case IDLE: lastIdleTime=millis(); if(((timeSinceCooling() > 900000UL || doNegPeakDetect==0) && (timeSinceHeating()>600000UL || doPosPeakDetect==0)) || state==STARTUP){ //if cooling is 15 min ago and heating 10 if(fridgeTempFilt[3]> fridgeTemperatureSetting+IDLE_RANGE_HIGH){ if(mode!=FRIDGE_CONSTANT){ if(beerTempFilt[3]>mainSettings.setpoint+6){ // only start cooling when beer is too warm (0.05 degree idle space) state=COOLING; } } else { state=COOLING; } return; } if(fridgeTempFilt[3]< fridgeTemperatureSetting+IDLE_RANGE_LOW){ if(mode!=FRIDGE_CONSTANT){ if(beerTempFilt[3]<mainSettings.setpoint-6){ // only start heating when beer is too cold (0.05 degree idle space) state=HEATING; } } else{ state=HEATING; } return; } } if(timeSinceCooling()>1800000UL){ //30 minutes doNegPeakDetect=0; //peak would be from drifting in idle, not from cooling } if(timeSinceHeating()>900000UL){ //20 minutes doPosPeakDetect=0; //peak would be from drifting in idle, not from heating } break; case COOLING: doNegPeakDetect=1; lastCoolTime = millis(); estimatedOvershoot = coolOvershootEstimator * min(MAX_COOL_TIME_FOR_ESTIMATE, (float) timeSinceIdle()/(1000))/60; estimatedPeakTemperature = fridgeTempFilt[3] - estimatedOvershoot; if(estimatedPeakTemperature <= fridgeTemperatureSetting + COOLING_TARGET){ fridgeSettingForNegPeakEstimate=fridgeTemperatureSetting; state=IDLE; return; } break; case HEATING: lastHeatTime=millis(); doPosPeakDetect=1; estimatedOvershoot = heatOvershootEstimator * min(MAX_HEAT_TIME_FOR_ESTIMATE, (float) timeSinceIdle()/(1000))/60; estimatedPeakTemperature = fridgeTempFilt[3] + estimatedOvershoot; if(estimatedPeakTemperature >= fridgeTemperatureSetting + HEATING_TARGET){ fridgeSettingForPosPeakEstimate=fridgeTemperatureSetting; state=IDLE; return; } break; default: state = IDLE; //go to idle, should never happen } }