use of android.filterfw.core.FrameFormat in project android_frameworks_base by ResurrectionRemix.
the class GrainFilter method process.
@Override
public void process(FilterContext context) {
// Get input frame
Frame input = pullInput("image");
FrameFormat inputFormat = input.getFormat();
FrameFormat noiseFormat = ImageFormat.create(inputFormat.getWidth() / 2, inputFormat.getHeight() / 2, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
// Create noise frame
Frame noiseFrame = context.getFrameManager().newFrame(inputFormat);
// Create output frame
Frame output = context.getFrameManager().newFrame(inputFormat);
// Create program if not created already
if (mNoiseProgram == null || mGrainProgram == null || inputFormat.getTarget() != mTarget) {
initProgram(context, inputFormat.getTarget());
updateParameters();
}
// Check if the frame size has changed
if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) {
updateFrameSize(inputFormat.getWidth(), inputFormat.getHeight());
}
Frame[] empty = {};
mNoiseProgram.process(empty, noiseFrame);
// Process
Frame[] inputs = { input, noiseFrame };
mGrainProgram.process(inputs, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
noiseFrame.release();
}
use of android.filterfw.core.FrameFormat in project android_frameworks_base by ResurrectionRemix.
the class ThroughputFilter method process.
@Override
public void process(FilterContext context) {
// Pass through input frame
Frame input = pullInput("frame");
pushOutput("frame", input);
// Update stats
++mTotalFrameCount;
++mPeriodFrameCount;
// Check clock
if (mLastTime == 0) {
mLastTime = SystemClock.elapsedRealtime();
}
long curTime = SystemClock.elapsedRealtime();
// Output throughput info if time period is up
if ((curTime - mLastTime) >= (mPeriod * 1000)) {
FrameFormat inputFormat = input.getFormat();
int pixelCount = inputFormat.getWidth() * inputFormat.getHeight();
Throughput throughput = new Throughput(mTotalFrameCount, mPeriodFrameCount, mPeriod, pixelCount);
Frame throughputFrame = context.getFrameManager().newFrame(mOutputFormat);
throughputFrame.setObjectValue(throughput);
pushOutput("throughput", throughputFrame);
mLastTime = curTime;
mPeriodFrameCount = 0;
}
}
use of android.filterfw.core.FrameFormat in project android_frameworks_base by ResurrectionRemix.
the class SimpleFrame method setGenericObjectValue.
@Override
protected void setGenericObjectValue(Object object) {
// Update the FrameFormat class
// TODO: Take this out! FrameFormats should not be modified and convenience formats used
// instead!
FrameFormat format = getFormat();
if (format.getObjectClass() == null) {
setFormatObjectClass(object.getClass());
} else if (!format.getObjectClass().isAssignableFrom(object.getClass())) {
throw new RuntimeException("Attempting to set object value of type '" + object.getClass() + "' on " + "SimpleFrame of type '" + format.getObjectClass() + "'!");
}
// Set the object value
mObject = object;
}
use of android.filterfw.core.FrameFormat in project android_frameworks_base by ResurrectionRemix.
the class GLTextureSource method process.
@Override
public void process(FilterContext context) {
// Generate frame if not generated already
if (mFrame == null) {
FrameFormat outputFormat = ImageFormat.create(mWidth, mHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
mFrame = context.getFrameManager().newBoundFrame(outputFormat, GLFrame.EXISTING_TEXTURE_BINDING, mTexId);
mFrame.setTimestamp(mTimestamp);
}
// Push output
pushOutput("frame", mFrame);
if (!mRepeatFrame) {
// Close output port as we are done here
closeOutputPort("frame");
}
}
use of android.filterfw.core.FrameFormat in project android_frameworks_base by ResurrectionRemix.
the class GLTextureTarget method process.
@Override
public void process(FilterContext context) {
// Get input frame
Frame input = pullInput("frame");
FrameFormat format = ImageFormat.create(input.getFormat().getWidth(), input.getFormat().getHeight(), ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
Frame frame = context.getFrameManager().newBoundFrame(format, GLFrame.EXISTING_TEXTURE_BINDING, mTexId);
// Copy to our texture frame
frame.setDataFromFrame(input);
frame.release();
}
Aggregations