From a84240d2cded1891a36287fcd82741d32d9c378c Mon Sep 17 00:00:00 2001 From: xufuji456 Date: Tue, 18 Oct 2022 15:35:53 +0800 Subject: [PATCH] Feature: reuse memory --- .../recorder/video/CameraVideoRecorder.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CameraFilter/src/main/java/com/frank/camerafilter/recorder/video/CameraVideoRecorder.java b/CameraFilter/src/main/java/com/frank/camerafilter/recorder/video/CameraVideoRecorder.java index f2aabc8..5cf703a 100644 --- a/CameraFilter/src/main/java/com/frank/camerafilter/recorder/video/CameraVideoRecorder.java +++ b/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 mRunning; - private Context mContext; private BaseFilter mFilter; + private final Context mContext; + private float[] mTransformMatrix; private FloatBuffer glVertexBuffer; private FloatBuffer glTextureBuffer; @@ -273,13 +274,15 @@ public class CameraVideoRecorder implements Runnable { if (!mReady) return; } - float[] transform = new float[16]; - surfaceTexture.getTransformMatrix(transform); + if (mTransformMatrix == null) { + mTransformMatrix = new float[16]; + } + surfaceTexture.getTransformMatrix(mTransformMatrix); long timestamp = surfaceTexture.getTimestamp(); if (timestamp == 0) { 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) {