Search in sources :

Example 46 with Frame

use of android.filterfw.core.Frame in project platform_frameworks_base by android.

the class SurfaceTextureTarget method process.

@Override
public synchronized void process(FilterContext context) {
    // Surface is not registered. Nothing to render into.
    if (mSurfaceId <= 0) {
        return;
    }
    GLEnvironment glEnv = context.getGLEnvironment();
    // Get input frame
    Frame input = pullInput("frame");
    boolean createdFrame = false;
    float currentAspectRatio = (float) input.getFormat().getWidth() / input.getFormat().getHeight();
    if (currentAspectRatio != mAspectRatio) {
        if (mLogVerbose) {
            Log.v(TAG, "Process. New aspect ratio: " + currentAspectRatio + ", previously: " + mAspectRatio + ". Thread: " + Thread.currentThread());
        }
        mAspectRatio = currentAspectRatio;
        updateTargetRect();
    }
    // See if we need to copy to GPU
    Frame gpuFrame = null;
    int target = input.getFormat().getTarget();
    if (target != FrameFormat.TARGET_GPU) {
        gpuFrame = context.getFrameManager().duplicateFrameToTarget(input, FrameFormat.TARGET_GPU);
        createdFrame = true;
    } else {
        gpuFrame = input;
    }
    // Activate our surface
    glEnv.activateSurfaceWithId(mSurfaceId);
    // Process
    mProgram.process(gpuFrame, mScreen);
    glEnv.setSurfaceTimestamp(input.getTimestamp());
    // And swap buffers
    glEnv.swapBuffers();
    if (createdFrame) {
        gpuFrame.release();
    }
}
Also used : GLEnvironment(android.filterfw.core.GLEnvironment) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame) Point(android.filterfw.geometry.Point)

Example 47 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.

the class FilterEffect method frameFromTexture.

/**
     * Converts a texture into a Frame.
     */
protected Frame frameFromTexture(int texId, int width, int height) {
    FrameManager manager = getFilterContext().getFrameManager();
    FrameFormat format = ImageFormat.create(width, height, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
    Frame frame = manager.newBoundFrame(format, GLFrame.EXISTING_TEXTURE_BINDING, texId);
    frame.setTimestamp(Frame.TIMESTAMP_UNKNOWN);
    return frame;
}
Also used : FrameFormat(android.filterfw.core.FrameFormat) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame) CachedFrameManager(android.filterfw.core.CachedFrameManager) FrameManager(android.filterfw.core.FrameManager)

Example 48 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.

the class SingleFilterEffect method apply.

@Override
public void apply(int inputTexId, int width, int height, int outputTexId) {
    beginGLEffect();
    Frame inputFrame = frameFromTexture(inputTexId, width, height);
    Frame outputFrame = frameFromTexture(outputTexId, width, height);
    Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame);
    outputFrame.setDataFromFrame(resultFrame);
    inputFrame.release();
    outputFrame.release();
    resultFrame.release();
    endGLEffect();
}
Also used : Frame(android.filterfw.core.Frame)

Example 49 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.

the class SizeChangeEffect method apply.

@Override
public void apply(int inputTexId, int width, int height, int outputTexId) {
    beginGLEffect();
    Frame inputFrame = frameFromTexture(inputTexId, width, height);
    Frame resultFrame = mFunction.executeWithArgList(mInputName, inputFrame);
    int outputWidth = resultFrame.getFormat().getWidth();
    int outputHeight = resultFrame.getFormat().getHeight();
    Frame outputFrame = frameFromTexture(outputTexId, outputWidth, outputHeight);
    outputFrame.setDataFromFrame(resultFrame);
    inputFrame.release();
    outputFrame.release();
    resultFrame.release();
    endGLEffect();
}
Also used : Frame(android.filterfw.core.Frame)

Example 50 with Frame

use of android.filterfw.core.Frame in project android_frameworks_base by ParanoidAndroid.

the class FilterContext method removeFrame.

public synchronized void removeFrame(String key) {
    Frame frame = mStoredFrames.get(key);
    if (frame != null) {
        mStoredFrames.remove(key);
        frame.release();
    }
}
Also used : Frame(android.filterfw.core.Frame)

Aggregations

Frame (android.filterfw.core.Frame)414 FrameFormat (android.filterfw.core.FrameFormat)198 GLFrame (android.filterfw.core.GLFrame)73 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)47 NativeFrame (android.filterfw.core.NativeFrame)38 Quad (android.filterfw.geometry.Quad)24 GLEnvironment (android.filterfw.core.GLEnvironment)18 ShaderProgram (android.filterfw.core.ShaderProgram)18 ByteBuffer (java.nio.ByteBuffer)18 Point (android.filterfw.geometry.Point)12 IOException (java.io.IOException)12 FrameManager (android.filterfw.core.FrameManager)6 Bitmap (android.graphics.Bitmap)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Map (java.util.Map)6 SortedMap (java.util.SortedMap)6 TreeMap (java.util.TreeMap)6 CachedFrameManager (android.filterfw.core.CachedFrameManager)1