use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class CropFilter method getOutputFormat.
@Override
public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
// Make sure output size is set to unspecified, as we do not know what we will be resizing
// to.
MutableFrameFormat outputFormat = inputFormat.mutableCopy();
outputFormat.setDimensions(FrameFormat.SIZE_UNSPECIFIED, FrameFormat.SIZE_UNSPECIFIED);
return outputFormat;
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class CropFilter method process.
@Override
public void process(FilterContext env) {
// Get input frame
Frame imageFrame = pullInput("image");
Frame boxFrame = pullInput("box");
createProgram(env, imageFrame.getFormat());
// Get the box
Quad box = (Quad) boxFrame.getObjectValue();
// Create output format
MutableFrameFormat outputFormat = imageFrame.getFormat().mutableCopy();
outputFormat.setDimensions(mOutputWidth == -1 ? outputFormat.getWidth() : mOutputWidth, mOutputHeight == -1 ? outputFormat.getHeight() : mOutputHeight);
// Create output frame
Frame output = env.getFrameManager().newFrame(outputFormat);
// Set the program parameters
if (mProgram instanceof ShaderProgram) {
ShaderProgram shaderProgram = (ShaderProgram) mProgram;
shaderProgram.setSourceRegion(box);
}
mProgram.process(imageFrame, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class FrameFormat method mutableCopy.
public MutableFrameFormat mutableCopy() {
MutableFrameFormat result = new MutableFrameFormat();
result.setBaseType(getBaseType());
result.setTarget(getTarget());
result.setBytesPerSample(getBytesPerSample());
result.setDimensions(getDimensions());
result.setObjectClass(getObjectClass());
result.mMetaData = mMetaData == null ? null : (KeyValueMap) mMetaData.clone();
return result;
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class ImageFormat method create.
public static MutableFrameFormat create(int width, int height, int colorspace, int bytesPerSample, int target) {
MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_BYTE, target);
result.setDimensions(width, height);
result.setBytesPerSample(bytesPerSample);
result.setMetaValue(COLORSPACE_KEY, colorspace);
if (target == FrameFormat.TARGET_SIMPLE) {
result.setObjectClass(Bitmap.class);
}
return result;
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class ObjectFormat method fromClass.
public static MutableFrameFormat fromClass(Class clazz, int count, int target) {
// Create frame format
MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target);
result.setObjectClass(getBoxedClass(clazz));
if (count != FrameFormat.SIZE_UNSPECIFIED) {
result.setDimensions(count);
}
result.setBytesPerSample(bytesPerSampleForClass(clazz, target));
return result;
}
Aggregations