static sp<AMessage> getMeasureFormat( bool isEncoder, const AString &mime, const sp<MediaCodecInfo::Capabilities> &caps) { sp<AMessage> format = new AMessage(); format->setString("mime", mime); if (isEncoder) { int32_t bitrate = 0; getMeasureBitrate(caps, &bitrate); format->setInt32("bitrate", bitrate); format->setInt32("encoder", 1); } if (mime.startsWith("video/")) { int32_t width = 0; int32_t height = 0; if (!getMeasureSize(caps, &width, &height)) { return NULL; } format->setInt32("width", width); format->setInt32("height", height); Vector<uint32_t> colorFormats; caps->getSupportedColorFormats(&colorFormats); if (colorFormats.size() == 0) { return NULL; } format->setInt32("color-format", colorFormats[0]); format->setFloat("frame-rate", 10.0); format->setInt32("i-frame-interval", 10); } else { // TODO: profile hw audio return NULL; } return format; }
ObserverBase::StateVector KalmanFilterBase::oneStepEstimation_() { unsigned k=this->x_.getTime(); BOOST_ASSERT(this->y_.size()> 0 && this->y_.checkIndex(k+1) && "ERROR: The measurement vector is not set"); BOOST_ASSERT(checkAmatrix(a_) && "ERROR: The Matrix A is not initialized" ); BOOST_ASSERT(checkCmatrix(c_) && "ERROR: The Matrix C is not initialized"); BOOST_ASSERT(checkQmatrix(q_) && "ERROR: The Matrix Q is not initialized"); BOOST_ASSERT(checkRmatrix(r_) && "ERROR: The Matrix R is not initialized"); BOOST_ASSERT(checkPmatrix(pr_) && "ERROR: The Matrix P is not initialized"); //prediction updatePredictedMeasurement();// runs also updatePrediction_(); oc_.pbar=q_; oc_.pbar.noalias() += a_*(pr_*a_.transpose()); //innovation Measurements oc_.inoMeas.noalias() = this->y_[k+1] - predictedMeasurement_; oc_.inoMeasCov.noalias() = r_ + c_ * (oc_.pbar * c_.transpose()); //inversing innovation measurement covariance matrix oc_.inoMeasCovLLT.compute(oc_.inoMeasCov); oc_.inoMeasCovInverse.resize(getMeasureSize(),getMeasureSize()); oc_.inoMeasCovInverse.setIdentity(); oc_.inoMeasCovLLT.matrixL().solveInPlace(oc_.inoMeasCovInverse); oc_.inoMeasCovLLT.matrixL().transpose().solveInPlace(oc_.inoMeasCovInverse); //innovation oc_.kGain.noalias() = oc_.pbar * (c_.transpose() * oc_.inoMeasCovInverse); inovation_.noalias() = oc_.kGain*oc_.inoMeas; //update oc_.xhat.noalias()= oc_.xbar+ inovation_; #ifdef VERBOUS_KALMANFILTER Eigen::IOFormat CleanFmt(2, 0, " ", "\n", "", ""); std::cout <<"A" <<std::endl<< a_.format(CleanFmt)<<std::endl; std::cout <<"C" <<std::endl<< c_.format(CleanFmt)<<std::endl; std::cout <<"P" <<std::endl<< pr_.format(CleanFmt)<<std::endl; std::cout <<"K" <<std::endl<< oc_.kGain.format(CleanFmt)<<std::endl; std::cout <<"Xbar" <<std::endl<< oc_.xbar.transpose().format(CleanFmt)<<std::endl; std::cout <<"inoMeasCov" <<std::endl<< oc_.inoMeasCov.format(CleanFmt)<<std::endl; std::cout <<"oc_.pbar" <<std::endl<< (oc_.pbar).format(CleanFmt)<<std::endl; std::cout <<"c_ * (oc_.pbar * c_.transpose())" <<std::endl<< ( c_ * (oc_.pbar * c_.transpose())).format(CleanFmt)<<std::endl; std::cout <<"inoMeasCovInverse" <<std::endl<< oc_.inoMeasCovInverse.format(CleanFmt)<<std::endl; std::cout <<"inoMeas" <<std::endl<< oc_.inoMeas.transpose().format(CleanFmt)<<std::endl; std::cout <<"inovation_" <<std::endl<< inovation_.transpose().format(CleanFmt)<<std::endl; std::cout <<"Xhat" <<std::endl<< oc_.xhat.transpose().format(CleanFmt)<<std::endl; #endif // VERBOUS_KALMANFILTER this->x_.set(oc_.xhat,k+1); pr_=oc_.stateIdentity; pr_ -= oc_.kGain*c_; pr_ *= oc_.pbar; // simmetrize the pr_ matrix oc_.t.noalias()=pr_; oc_.t+=pr_.transpose(); pr_=0.5*oc_.t; return oc_.xhat; }
void printBarlines(HumdrumFile& infile, int numberheight, int numberwidth) { int i, j; Array<Array<int> > xaxis; xaxis.setSize(numberheight-1); xaxis.allowGrowth(0); for (i=0; i<xaxis.getSize(); i++) { xaxis[i].setSize(numberwidth); xaxis[i].allowGrowth(0); xaxis[i].setAll(24); } // bar counter keeps track of multiple repeats of the same // music. Array<int> barcount(10000); barcount.allowGrowth(0); barcount.setAll(0); double measuresize = getMeasureSize(infile, numberwidth); int size; int style = 0; int position; int number; for (i=0; i<infile.getNumLines(); i++) { if (!infile[i].isMeasure()) { continue; } size = 0; position = -1; if (sscanf(infile[i][0], "=%d", &number)) { if ((number >= 0) && (number < barcount.getSize())) { style = barcount[number]; barcount[number]++; } else { style = 0; } position = int(numberwidth * infile[i].getAbsBeat() / infile.getTotalDuration() + 0.5); if ((number % 100) == 0) { size = 10; } else if ((number % 50) == 0) { size = 8; } else if ((number % 10) == 0) { size = 6; } else if ((number % 5) == 0) { size = 4; } else { size = 2; if (measuresize < 3) { // don't display single measure ticks if they // are too closely spaced size = 0; } } } int color; if ((position >= 0) && (size > 0)) { for (j=0; j<size; j++) { if (style == 0) { color = 25; } else if (style == 1) { color = 4; // red (in default color) } else if (style == 2) { color = 2; // blue (in default color) } else if (style == 3) { color = 0; // green (in default color) } else { color = 11; // orange (in default color) } xaxis[j][position] = color; if (j==9) { if (position>0) { xaxis[j][position-1] = color; } if (position<xaxis[0].getSize()-1) { xaxis[j][position+1] = color; } } } } } // print a empty line so that small measure markers can be seen for (i=0; i<xaxis[0].getSize(); i++) { cout << ' ' << colorindex[24]; } cout << '\n'; for (i=0; i<xaxis.getSize(); i++) { for (j=0; j<xaxis[i].getSize(); j++) { cout << ' ' << colorindex[xaxis[i][j]]; } cout << '\n'; } }