FileDocCategorySizeDatePackage
FillLightFilter.javaAPI DocAndroid 5.1 API4496Thu Mar 12 22:22:30 GMT 2015android.filterpacks.imageproc

FillLightFilter

public class FillLightFilter extends android.filterfw.core.Filter

Fields Summary
private int
mTileSize
private float
mBacklight
private android.filterfw.core.Program
mProgram
private int
mTarget
private final String
mFillLightShader
Constructors Summary
public FillLightFilter(String name)


       
      super(name);
    
Methods Summary
public voidfieldPortValueUpdated(java.lang.String name, android.filterfw.core.FilterContext context)

        if (mProgram != null) {
            updateParameters();
        }
    
public android.filterfw.core.FrameFormatgetOutputFormat(java.lang.String portName, android.filterfw.core.FrameFormat inputFormat)

        return inputFormat;
    
public voidinitProgram(android.filterfw.core.FilterContext context, int target)

        switch (target) {
            case FrameFormat.TARGET_GPU:
                ShaderProgram shaderProgram = new ShaderProgram(context, mFillLightShader);
                Log.e("FillLight", "tile size: " + mTileSize);
                shaderProgram.setMaximumTileSize(mTileSize);
                mProgram = shaderProgram;
                break;

            default:
                throw new RuntimeException("Filter FillLight does not support frames of " +
                    "target " + target + "!");
        }
        mTarget = target;
    
public voidprocess(android.filterfw.core.FilterContext context)

        // Get input frame
        Frame input = pullInput("image");
        FrameFormat inputFormat = input.getFormat();

        // Create output frame
        Frame output = context.getFrameManager().newFrame(inputFormat);

        // Create program if not created already
        if (mProgram == null || inputFormat.getTarget() != mTarget) {
            initProgram(context, inputFormat.getTarget());
            updateParameters();
        }

        // Process
        mProgram.process(input, output);

        // Push output
        pushOutput("image", output);

        // Release pushed frame
        output.release();
    
public voidsetupPorts()

        addMaskedInputPort("image", ImageFormat.create(ImageFormat.COLORSPACE_RGBA));
        addOutputBasedOnInput("image", "image");
    
private voidupdateParameters()

        float fade_gamma = 0.3f;
        float amt = 1.0f - mBacklight;
        float mult = 1.0f / (amt * 0.7f + 0.3f);
        float faded = fade_gamma + (1.0f -fade_gamma) *mult;
        float igamma = 1.0f / faded;

        mProgram.setHostValue("mult", mult);
        mProgram.setHostValue("igamma", igamma);