Feature: reuse memory

pull/221/head
xufuji456 2 years ago
parent be37dabaca
commit a84240d2cd
  1. 11
      CameraFilter/src/main/java/com/frank/camerafilter/recorder/video/CameraVideoRecorder.java

@ -65,8 +65,9 @@ public class CameraVideoRecorder implements Runnable {
private boolean mReady; private boolean mReady;
private boolean mRunning; private boolean mRunning;
private Context mContext;
private BaseFilter mFilter; private BaseFilter mFilter;
private final Context mContext;
private float[] mTransformMatrix;
private FloatBuffer glVertexBuffer; private FloatBuffer glVertexBuffer;
private FloatBuffer glTextureBuffer; private FloatBuffer glTextureBuffer;
@ -273,13 +274,15 @@ public class CameraVideoRecorder implements Runnable {
if (!mReady) if (!mReady)
return; return;
} }
float[] transform = new float[16]; if (mTransformMatrix == null) {
surfaceTexture.getTransformMatrix(transform); mTransformMatrix = new float[16];
}
surfaceTexture.getTransformMatrix(mTransformMatrix);
long timestamp = surfaceTexture.getTimestamp(); long timestamp = surfaceTexture.getTimestamp();
if (timestamp == 0) { if (timestamp == 0) {
return; return;
} }
mHandler.sendMessage(mHandler.obtainMessage(MSG_FRAME_AVAILABLE, (int) (timestamp >> 32), (int) timestamp, transform)); mHandler.sendMessage(mHandler.obtainMessage(MSG_FRAME_AVAILABLE, (int) (timestamp >> 32), (int) timestamp, mTransformMatrix));
} }
public void setTextureId(int id) { public void setTextureId(int id) {

Loading…
Cancel
Save