Back to project page cameraMediaCodec.
The source code is released under:
Copyright (c) 2014, Zhang Ziyue All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * ...
If you think the Android project cameraMediaCodec listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.android.testtool; // w w w . j av a 2 s .c om //this tool can only filter average distributed frames. If some frames are tight and some are loose, it cannot handle the case. public class FpsHelper { boolean mEnableDrop = false; int mTargetFps = 0; long mResetTimestamp = 0; long mPassedFrames = 0; public void SetEnableDrop(boolean enable) { mEnableDrop = enable; } public void SetFrameRateControlTarget(int fps) { mTargetFps = fps; mResetTimestamp = 0; mPassedFrames = 0; } public boolean ShouldBeDropped(long timestamp) { if (mEnableDrop == false) { return false; } if (mResetTimestamp == 0 || (mResetTimestamp!= 0 && timestamp < mResetTimestamp) ) { mPassedFrames = 0; mResetTimestamp = timestamp; return false; } long delta = timestamp - mResetTimestamp; long framesShouldPass = delta * mTargetFps / 1000; if (framesShouldPass > mPassedFrames) { mPassedFrames ++; return false; } else { return true; } } }