use of android.filterfw.core.ShaderProgram in project android_frameworks_base by AOSPA.
the class BackDropperFilter method allocateFrames.
private void allocateFrames(FrameFormat inputFormat, FilterContext context) {
if (!createMemoryFormat(inputFormat)) {
// All set.
return;
}
if (mLogVerbose)
Log.v(TAG, "Allocating BackDropperFilter frames");
// Create initial background model values
int numBytes = mMaskFormat.getSize();
byte[] initialBgMean = new byte[numBytes];
byte[] initialBgVariance = new byte[numBytes];
byte[] initialMaskVerify = new byte[numBytes];
for (int i = 0; i < numBytes; i++) {
initialBgMean[i] = (byte) 128;
initialBgVariance[i] = (byte) 10;
initialMaskVerify[i] = (byte) 0;
}
// Get frames to store background model in
for (int i = 0; i < 2; i++) {
mBgMean[i] = (GLFrame) context.getFrameManager().newFrame(mMaskFormat);
mBgMean[i].setData(initialBgMean, 0, numBytes);
mBgVariance[i] = (GLFrame) context.getFrameManager().newFrame(mMaskFormat);
mBgVariance[i].setData(initialBgVariance, 0, numBytes);
mMaskVerify[i] = (GLFrame) context.getFrameManager().newFrame(mMaskFormat);
mMaskVerify[i].setData(initialMaskVerify, 0, numBytes);
}
// Get frames to store other textures in
if (mLogVerbose)
Log.v(TAG, "Done allocating texture for Mean and Variance objects!");
mDistance = (GLFrame) context.getFrameManager().newFrame(mMaskFormat);
mMask = (GLFrame) context.getFrameManager().newFrame(mMaskFormat);
mAutoWB = (GLFrame) context.getFrameManager().newFrame(mAverageFormat);
mVideoInput = (GLFrame) context.getFrameManager().newFrame(mMemoryFormat);
mBgInput = (GLFrame) context.getFrameManager().newFrame(mMemoryFormat);
mMaskAverage = (GLFrame) context.getFrameManager().newFrame(mAverageFormat);
// Create shader programs
mBgDistProgram = new ShaderProgram(context, mSharedUtilShader + mBgDistanceShader);
mBgDistProgram.setHostValue("subsample_level", (float) mSubsampleLevel);
mBgMaskProgram = new ShaderProgram(context, mSharedUtilShader + mBgMaskShader);
mBgMaskProgram.setHostValue("accept_variance", mAcceptStddev * mAcceptStddev);
float[] yuvWeights = { mLumScale, mChromaScale };
mBgMaskProgram.setHostValue("yuv_weights", yuvWeights);
mBgMaskProgram.setHostValue("scale_lrg", mHierarchyLrgScale);
mBgMaskProgram.setHostValue("scale_mid", mHierarchyMidScale);
mBgMaskProgram.setHostValue("scale_sml", mHierarchySmlScale);
mBgMaskProgram.setHostValue("exp_lrg", (float) (mSubsampleLevel + mHierarchyLrgExp));
mBgMaskProgram.setHostValue("exp_mid", (float) (mSubsampleLevel + mHierarchyMidExp));
mBgMaskProgram.setHostValue("exp_sml", (float) (mSubsampleLevel + mHierarchySmlExp));
if (mUseTheForce) {
mBgSubtractProgram = new ShaderProgram(context, mSharedUtilShader + mBgSubtractShader + mBgSubtractForceShader);
} else {
mBgSubtractProgram = new ShaderProgram(context, mSharedUtilShader + mBgSubtractShader + "}\n");
}
mBgSubtractProgram.setHostValue("bg_fit_transform", DEFAULT_BG_FIT_TRANSFORM);
mBgSubtractProgram.setHostValue("mask_blend_bg", mMaskBg);
mBgSubtractProgram.setHostValue("mask_blend_fg", mMaskFg);
mBgSubtractProgram.setHostValue("exposure_change", mExposureChange);
mBgSubtractProgram.setHostValue("whitebalanceblue_change", mWhiteBalanceBlueChange);
mBgSubtractProgram.setHostValue("whitebalancered_change", mWhiteBalanceRedChange);
mBgUpdateMeanProgram = new ShaderProgram(context, mSharedUtilShader + mUpdateBgModelMeanShader);
mBgUpdateMeanProgram.setHostValue("subsample_level", (float) mSubsampleLevel);
mBgUpdateVarianceProgram = new ShaderProgram(context, mSharedUtilShader + mUpdateBgModelVarianceShader);
mBgUpdateVarianceProgram.setHostValue("subsample_level", (float) mSubsampleLevel);
mCopyOutProgram = ShaderProgram.createIdentity(context);
mAutomaticWhiteBalanceProgram = new ShaderProgram(context, mSharedUtilShader + mAutomaticWhiteBalance);
mAutomaticWhiteBalanceProgram.setHostValue("pyramid_depth", (float) mPyramidDepth);
mAutomaticWhiteBalanceProgram.setHostValue("autowb_toggle", mAutoWBToggle);
mMaskVerifyProgram = new ShaderProgram(context, mSharedUtilShader + mMaskVerifyShader);
mMaskVerifyProgram.setHostValue("verify_rate", mVerifyRate);
if (mLogVerbose)
Log.v(TAG, "Shader width set to " + mMemoryFormat.getWidth());
mRelativeAspect = 1.f;
mFrameCount = 0;
mStartLearning = true;
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by AOSPA.
the class MediaSource method prepare.
@Override
protected void prepare(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Preparing MediaSource");
mFrameExtractor = new ShaderProgram(context, mFrameShader);
// SurfaceTexture defines (0,0) to be bottom-left. The filter framework
// defines (0,0) as top-left, so do the flip here.
mFrameExtractor.setSourceRect(0, 1, 1, -1);
createFormats();
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by AOSPA.
the class BlackWhiteFilter method initProgram.
public void initProgram(FilterContext context, int target) {
switch(target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mBlackWhiteShader);
shaderProgram.setMaximumTileSize(mTileSize);
mProgram = shaderProgram;
updateParameters();
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " + "target " + target + "!");
}
mTarget = target;
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by AOSPA.
the class ColorTemperatureFilter method initProgram.
public void initProgram(FilterContext context, int target) {
switch(target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mColorTemperatureShader);
shaderProgram.setMaximumTileSize(mTileSize);
mProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter Sharpen does not support frames of " + "target " + target + "!");
}
mTarget = target;
}
use of android.filterfw.core.ShaderProgram in project android_frameworks_base by AOSPA.
the class CrossProcessFilter method initProgram.
public void initProgram(FilterContext context, int target) {
switch(target) {
case FrameFormat.TARGET_GPU:
ShaderProgram shaderProgram = new ShaderProgram(context, mCrossProcessShader);
shaderProgram.setMaximumTileSize(mTileSize);
mProgram = shaderProgram;
break;
default:
throw new RuntimeException("Filter CrossProcess does not support frames of " + "target " + target + "!");
}
mTarget = target;
}
Aggregations