From 08410e716200090d69cd772d30a8efd1b0facd85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Kalliom=C3=A4ki?= Date: Mon, 23 Jul 2018 11:04:46 +0200 Subject: [PATCH] Remove dead code from videoframe.cc. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removes dead code that was left by a previous cleanup. Bug: webrtc:9181 Change-Id: Iad7a747b4b394bfe16767229b7840a49a044c516 Reviewed-on: https://webrtc-review.googlesource.com/90042 Reviewed-by: Paulina Hensman Commit-Queue: Sami Kalliomäki Cr-Commit-Position: refs/heads/master@{#24062} --- sdk/android/src/jni/androidvideotracksource.h | 13 -- sdk/android/src/jni/videoframe.cc | 114 ------------------ sdk/android/src/jni/videoframe.h | 41 ------- 3 files changed, 168 deletions(-) diff --git a/sdk/android/src/jni/androidvideotracksource.h b/sdk/android/src/jni/androidvideotracksource.h index 3c4d1ef663..8f092c1b04 100644 --- a/sdk/android/src/jni/androidvideotracksource.h +++ b/sdk/android/src/jni/androidvideotracksource.h @@ -46,19 +46,6 @@ class AndroidVideoTrackSource : public rtc::AdaptedVideoTrackSource { bool remote() const override; - void OnByteBufferFrameCaptured(const void* frame_data, - int length, - int width, - int height, - VideoRotation rotation, - int64_t timestamp_ns); - - void OnTextureFrameCaptured(int width, - int height, - VideoRotation rotation, - int64_t timestamp_ns, - const NativeHandleImpl& handle); - void OnFrameCaptured(JNIEnv* jni, int width, int height, diff --git a/sdk/android/src/jni/videoframe.cc b/sdk/android/src/jni/videoframe.cc index 309e2da80b..aeb43bcefc 100644 --- a/sdk/android/src/jni/videoframe.cc +++ b/sdk/android/src/jni/videoframe.cc @@ -123,120 +123,6 @@ int64_t GetJavaVideoFrameTimestampNs(JNIEnv* jni, return Java_VideoFrame_getTimestampNs(jni, j_video_frame); } -Matrix::Matrix(JNIEnv* jni, const JavaRef& a) { - RTC_CHECK_EQ(16, jni->GetArrayLength(a.obj())); - jni->GetFloatArrayRegion(a.obj(), 0, 16, elem_); -} - -ScopedJavaLocalRef Matrix::ToJava(JNIEnv* jni) const { - ScopedJavaLocalRef matrix(jni, jni->NewFloatArray(16)); - jni->SetFloatArrayRegion(matrix.obj(), 0, 16, elem_); - return matrix; -} - -void Matrix::Rotate(VideoRotation rotation) { - // Texture coordinates are in the range 0 to 1. The transformation of the last - // row in each rotation matrix is needed for proper translation, e.g, to - // mirror x, we don't replace x by -x, but by 1-x. - switch (rotation) { - case kVideoRotation_0: - break; - case kVideoRotation_90: { - const float ROTATE_90[16] = {elem_[4], - elem_[5], - elem_[6], - elem_[7], - -elem_[0], - -elem_[1], - -elem_[2], - -elem_[3], - elem_[8], - elem_[9], - elem_[10], - elem_[11], - elem_[0] + elem_[12], - elem_[1] + elem_[13], - elem_[2] + elem_[14], - elem_[3] + elem_[15]}; - memcpy(elem_, ROTATE_90, sizeof(elem_)); - } break; - case kVideoRotation_180: { - const float ROTATE_180[16] = {-elem_[0], - -elem_[1], - -elem_[2], - -elem_[3], - -elem_[4], - -elem_[5], - -elem_[6], - -elem_[7], - elem_[8], - elem_[9], - elem_[10], - elem_[11], - elem_[0] + elem_[4] + elem_[12], - elem_[1] + elem_[5] + elem_[13], - elem_[2] + elem_[6] + elem_[14], - elem_[3] + elem_[11] + elem_[15]}; - memcpy(elem_, ROTATE_180, sizeof(elem_)); - } break; - case kVideoRotation_270: { - const float ROTATE_270[16] = {-elem_[4], - -elem_[5], - -elem_[6], - -elem_[7], - elem_[0], - elem_[1], - elem_[2], - elem_[3], - elem_[8], - elem_[9], - elem_[10], - elem_[11], - elem_[4] + elem_[12], - elem_[5] + elem_[13], - elem_[6] + elem_[14], - elem_[7] + elem_[15]}; - memcpy(elem_, ROTATE_270, sizeof(elem_)); - } break; - } -} - -// Calculates result = a * b, in column-major order. -void Matrix::Multiply(const float a[16], const float b[16], float result[16]) { - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) { - float sum = 0; - for (int k = 0; k < 4; ++k) { - sum += a[k * 4 + j] * b[i * 4 + k]; - } - result[i * 4 + j] = sum; - } - } -} - -// Center crop by keeping xFraction of the width and yFraction of the height, -// so e.g. cropping from 640x480 to 640x360 would use -// xFraction=1, yFraction=360/480. -void Matrix::Crop(float xFraction, - float yFraction, - float xOffset, - float yOffset) { - const float crop_matrix[16] = {xFraction, 0, 0, 0, 0, yFraction, 0, 0, - 0, 0, 1, 0, xOffset, yOffset, 0, 1}; - const Matrix old = *this; - Multiply(crop_matrix, old.elem_, this->elem_); -} - -NativeHandleImpl::NativeHandleImpl(int id, const Matrix& matrix) - : oes_texture_id(id), sampling_matrix(matrix) {} - -NativeHandleImpl::NativeHandleImpl( - JNIEnv* jni, - jint j_oes_texture_id, - const JavaRef& j_transform_matrix) - : oes_texture_id(j_oes_texture_id), - sampling_matrix(jni, j_transform_matrix) {} - rtc::scoped_refptr AndroidVideoBuffer::Adopt( JNIEnv* jni, const JavaRef& j_video_frame_buffer) { diff --git a/sdk/android/src/jni/videoframe.h b/sdk/android/src/jni/videoframe.h index 8b99701268..107e03e17b 100644 --- a/sdk/android/src/jni/videoframe.h +++ b/sdk/android/src/jni/videoframe.h @@ -22,47 +22,6 @@ namespace webrtc { namespace jni { -// TODO(sakal): Remove once clients have migrated. -using ::webrtc::JavaParamRef; - -// Open gl texture matrix, in column-major order. Operations are -// in-place. -class Matrix { - public: - Matrix(JNIEnv* jni, const JavaRef& a); - - static Matrix fromAndroidGraphicsMatrix(JNIEnv* jni, - const JavaRef& j_matrix); - - ScopedJavaLocalRef ToJava(JNIEnv* jni) const; - - // Crop arguments are relative to original size. - void Crop(float cropped_width, - float cropped_height, - float crop_x, - float crop_y); - - void Rotate(VideoRotation rotation); - - private: - Matrix() {} - - static void Multiply(const float a[16], const float b[16], float result[16]); - float elem_[16]; -}; - -// Wrapper for texture object. -struct NativeHandleImpl { - NativeHandleImpl(JNIEnv* jni, - jint j_oes_texture_id, - const JavaRef& j_transform_matrix); - - NativeHandleImpl(int id, const Matrix& matrix); - - const int oes_texture_id; - Matrix sampling_matrix; -}; - class AndroidVideoBuffer : public VideoFrameBuffer { public: // Creates a native VideoFrameBuffer from a Java VideoFrame.Buffer.