Index: webrtc/api/java/jni/native_handle_impl.cc |
diff --git a/webrtc/api/java/jni/native_handle_impl.cc b/webrtc/api/java/jni/native_handle_impl.cc |
index 1f180ade9cc79ff33bcd6f1174d6817e44187b4a..a0706367878d810bc3453e367cd0df7939f5a815 100644 |
--- a/webrtc/api/java/jni/native_handle_impl.cc |
+++ b/webrtc/api/java/jni/native_handle_impl.cc |
@@ -75,11 +75,8 @@ void MultiplyMatrix(const float a[16], const float b[16], float result[16]) { |
// 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 CropMatrix(float a[16], float xFraction, float yFraction) { |
- // Move cropped area to the center of the frame by offsetting half the |
- // removed area. |
- const float xOffset = (1 - xFraction) / 2; |
- const float yOffset = (1 - yFraction) / 2; |
+void CropMatrix(float a[16], float xFraction, float yFraction, |
+ float xOffset, float yOffset) { |
const float crop_matrix[16] = { |
xFraction, 0, 0, 0, |
0, yFraction, 0, 0, |
@@ -179,6 +176,8 @@ AndroidTextureBuffer::NativeToI420Buffer() { |
rtc::scoped_refptr<AndroidTextureBuffer> |
AndroidTextureBuffer::CropScaleAndRotate(int cropped_width, |
int cropped_height, |
+ int crop_x, |
+ int crop_y, |
int dst_width, |
int dst_height, |
webrtc::VideoRotation rotation) { |
@@ -200,7 +199,9 @@ AndroidTextureBuffer::CropScaleAndRotate(int cropped_width, |
if (cropped_width != width() || cropped_height != height()) { |
CropMatrix(buffer->native_handle_.sampling_matrix, |
cropped_width / static_cast<float>(width()), |
- cropped_height / static_cast<float>(height())); |
+ cropped_height / static_cast<float>(height()), |
+ crop_x / static_cast<float>(width()), |
+ crop_y / static_cast<float>(height())); |
} |
RotateMatrix(buffer->native_handle_.sampling_matrix, rotation); |
return buffer; |