@DSGenerator( tool_name = "Doppelganger", tool_version = "2.0", generated_on = "2014-03-24 16:06:05.610 -0400", hash_original_method = "CDA5C14F8CDCE778A8FB11BE8150AA9D", hash_generated_method = "3FFDA852F4258D4F3758CE4950CDFF55") @Override public Frame newBoundFrame(FrameFormat format, int bindingType, long bindingId) { Frame result = null; switch (format.getTarget()) { case FrameFormat.TARGET_GPU: { GLFrame glFrame = new GLFrame(format, this, bindingType, bindingId); glFrame.init(getGLEnvironment()); result = glFrame; break; } default: throw new RuntimeException( "Attached frames are not supported for target type: " + FrameFormat.targetToString(format.getTarget()) + "!"); } return result; }
@Override public void process(FilterContext context) { // Get input frame Frame input = pullInput("image"); FrameFormat inputFormat = input.getFormat(); // Create program if not created already if (mProgram == null || inputFormat.getTarget() != mTarget) { initProgram(context, inputFormat.getTarget()); } // Check if the frame size has changed if (inputFormat.getWidth() != mWidth || inputFormat.getHeight() != mHeight) { mWidth = inputFormat.getWidth(); mHeight = inputFormat.getHeight(); initParameters(); } // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); // Process mProgram.process(input, output); // Push output pushOutput("image", output); // Release pushed frame output.release(); }
@DSGenerator( tool_name = "Doppelganger", tool_version = "2.0", generated_on = "2014-03-24 16:06:05.612 -0400", hash_original_method = "D9BBB52F9327CED81F2FD031D449BDDB", hash_generated_method = "BEBB154B0E0C4A7B71B71BFF09B6D9F8") private Frame createNewFrame(FrameFormat format) { Frame result = null; switch (format.getTarget()) { case FrameFormat.TARGET_SIMPLE: result = new SimpleFrame(format, this); break; case FrameFormat.TARGET_NATIVE: result = new NativeFrame(format, this); break; case FrameFormat.TARGET_GPU: { GLFrame glFrame = new GLFrame(format, this); glFrame.init(getGLEnvironment()); result = glFrame; break; } case FrameFormat.TARGET_VERTEXBUFFER: { result = new VertexFrame(format, this); break; } default: throw new RuntimeException( "Unsupported frame target type: " + FrameFormat.targetToString(format.getTarget()) + "!"); } return result; }
@Override public void process(FilterContext context) { // Get input frame Frame input = pullInput("image"); FrameFormat inputFormat = input.getFormat(); // Create program if not created already if (mProgram == null || inputFormat.getTarget() != mTarget) { initProgram(context, inputFormat.getTarget()); updateParameters(); } // Create output frame Frame output = context.getFrameManager().newFrame(inputFormat); // Process mProgram.process(input, output); // Push output pushOutput("image", output); // Release pushed frame output.release(); }
@Override public boolean process( FilterContext context, VideoEventFilter myfilter, boolean isRenderOutput, GLFrame output) { super.process(context, myfilter, isRenderOutput, output); GLFrame camera = myfilter.getInputCameraGLFrame(); FrameFormat inputFormat; inputFormat = camera.getFormat(); if (null == mMainFrame) { MutableFrameFormat outputFormat = inputFormat.mutableCopy(); mMainFrame = (GLFrame) context.getFrameManager().newFrame(outputFormat); mMainFrame.focus(); mCopyProgramWithColor.process(camera, mMainFrame); } if (null == mPreviousFrame) { MutableFrameFormat outputFormat = inputFormat.mutableCopy(); mPreviousFrame = (GLFrame) context.getFrameManager().newFrame(outputFormat); mPreviousFrame.focus(); } Frame[] subtractInputs = {camera, mPreviousFrame}; long currentTimeStamp = myfilter.getNowTimeStamp(); long cameraPhoto; if (this.containsKey("camera_photo")) { try { cameraPhoto = ((Long) this.get("camera_photo")).longValue() + mStart; } catch (ClassCastException e) { e.printStackTrace(); return false; } // get fix frame if (currentTimeStamp >= cameraPhoto) { if (false == mGotMainFrame) { mMainFrame.focus(); mColor[3] = 1.0f; mCopyProgramWithColor.setHostValue("ccc", mColor); mCopyProgramWithColor.process(camera, mMainFrame); mGotMainFrame = true; mTool.log('d', "Got CameraInput:" + currentTimeStamp); } subtractInputs[0] = mMainFrame; } if (false == mIsGotPreviousFrame || true == mIsGotPreviousFrame && currentTimeStamp < mEffectStart) { mPreviousFrame.focus(); if (isRenderOutput) { mCopyProgramWithColor.process(output, mPreviousFrame); } else { mCopyProgramWithColor.process(camera, mPreviousFrame); } mIsGotPreviousFrame = true; mTool.log('d', "Got PreviousInput:" + currentTimeStamp); } // finished, no need to do if (currentTimeStamp >= mEffectEnd || currentTimeStamp < mEffectStart) { return false; } float center_r = 0.0f; if (cameraPhoto >= currentTimeStamp) { center_r = 1.0f - (float) (currentTimeStamp - mEffectStart) / (float) (cameraPhoto - mEffectStart); subtractInputs[0] = mPreviousFrame; } else { center_r = (float) (currentTimeStamp - cameraPhoto) / (float) (mEffectEnd - cameraPhoto); subtractInputs[0] = mMainFrame; } mCopyProgram.setHostValue("center_r", center_r); if (null != output && isRenderOutput == false) { mCopyProgram.process(subtractInputs, output); } return true; } return false; }
Frame(FrameFormat format, FrameManager frameManager, int bindingType, long bindingId) { mFormat = format.mutableCopy(); mFrameManager = frameManager; mBindingType = bindingType; mBindingId = bindingId; }
Frame(FrameFormat format, FrameManager frameManager) { mFormat = format.mutableCopy(); mFrameManager = frameManager; }
protected void reset(FrameFormat newFormat) { mFormat = newFormat.mutableCopy(); mReadOnly = false; mRefCount = 1; }
protected void setFormat(FrameFormat format) { mFormat = format.mutableCopy(); }