Search in sources :

Example 61 with FrameFormat

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();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame)

Example 62 with FrameFormat

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;
    }
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame)

Example 63 with FrameFormat

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;
}
Also used : FrameFormat(android.filterfw.core.FrameFormat)

Example 64 with FrameFormat

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");
    }
}
Also used : FrameFormat(android.filterfw.core.FrameFormat)

Example 65 with FrameFormat

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();
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame)

Aggregations

FrameFormat (android.filterfw.core.FrameFormat)270 Frame (android.filterfw.core.Frame)198 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)39 NativeFrame (android.filterfw.core.NativeFrame)25 GLFrame (android.filterfw.core.GLFrame)18 ShaderProgram (android.filterfw.core.ShaderProgram)12 Quad (android.filterfw.geometry.Quad)12 FrameManager (android.filterfw.core.FrameManager)6 Point (android.filterfw.geometry.Point)6 Bitmap (android.graphics.Bitmap)6 Paint (android.graphics.Paint)6 CachedFrameManager (android.filterfw.core.CachedFrameManager)1