use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by DirtyUnicorns.
the class ImageStitcher method calcOutputFormatForInput.
private FrameFormat calcOutputFormatForInput(FrameFormat format) {
MutableFrameFormat outputFormat = format.mutableCopy();
mInputWidth = format.getWidth();
mInputHeight = format.getHeight();
mSliceWidth = mInputWidth - 2 * mPadSize;
mSliceHeight = mInputHeight - 2 * mPadSize;
mImageWidth = mSliceWidth * mXSlices;
mImageHeight = mSliceHeight * mYSlices;
outputFormat.setDimensions(mImageWidth, mImageHeight);
return outputFormat;
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by DirtyUnicorns.
the class ToPackedGrayFilter method process.
@Override
public void process(FilterContext context) {
Frame input = pullInput("image");
FrameFormat inputFormat = input.getFormat();
FrameFormat outputFormat = convertInputFormat(inputFormat);
int ow = outputFormat.getWidth();
int oh = outputFormat.getHeight();
checkOutputDimensions(ow, oh);
mProgram.setHostValue("pix_stride", 1.0f / ow);
// Do the RGBA to luminance conversion.
MutableFrameFormat tempFrameFormat = inputFormat.mutableCopy();
tempFrameFormat.setDimensions(ow / 4, oh);
Frame temp = context.getFrameManager().newFrame(tempFrameFormat);
mProgram.process(input, temp);
// Read frame from GPU to CPU.
Frame output = context.getFrameManager().newFrame(outputFormat);
output.setDataFromFrame(temp);
temp.release();
// Push output and yield ownership.
pushOutput("image", output);
output.release();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by DirtyUnicorns.
the class FixedRotationFilter method process.
@Override
public void process(FilterContext context) {
Frame input = pullInput("image");
if (mRotation == 0) {
pushOutput("image", input);
return;
}
FrameFormat inputFormat = input.getFormat();
// Create program if not created already
if (mProgram == null) {
mProgram = ShaderProgram.createIdentity(context);
}
MutableFrameFormat outputFormat = inputFormat.mutableCopy();
int width = inputFormat.getWidth();
int height = inputFormat.getHeight();
Point p1 = new Point(0.0f, 0.0f);
Point p2 = new Point(1.0f, 0.0f);
Point p3 = new Point(0.0f, 1.0f);
Point p4 = new Point(1.0f, 1.0f);
Quad sourceRegion;
switch(((int) Math.round(mRotation / 90f)) % 4) {
case 1:
sourceRegion = new Quad(p3, p1, p4, p2);
outputFormat.setDimensions(height, width);
break;
case 2:
sourceRegion = new Quad(p4, p3, p2, p1);
break;
case 3:
sourceRegion = new Quad(p2, p4, p1, p3);
outputFormat.setDimensions(height, width);
break;
case 0:
default:
sourceRegion = new Quad(p1, p2, p3, p4);
break;
}
// Create output frame
Frame output = context.getFrameManager().newFrame(outputFormat);
// Set the source region
mProgram.setSourceRegion(sourceRegion);
// Process
mProgram.process(input, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by DirtyUnicorns.
the class ToRGBAFilter method getConvertedFormat.
public FrameFormat getConvertedFormat(FrameFormat format) {
MutableFrameFormat result = format.mutableCopy();
result.setMetaValue(ImageFormat.COLORSPACE_KEY, ImageFormat.COLORSPACE_RGBA);
result.setBytesPerSample(4);
return result;
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by DirtyUnicorns.
the class ToRGBFilter method setupPorts.
@Override
public void setupPorts() {
MutableFrameFormat mask = new MutableFrameFormat(FrameFormat.TYPE_BYTE, FrameFormat.TARGET_NATIVE);
mask.setDimensionCount(2);
addMaskedInputPort("image", mask);
addOutputBasedOnInput("image", "image");
}
Aggregations