From acdaaaf29a73923f4ce8e447151d1b8fafbcc785 Mon Sep 17 00:00:00 2001 From: Magnus Jedvert Date: Mon, 23 Apr 2018 14:49:49 +0200 Subject: [PATCH] Android: Fix cropping logic for NV12/NV21 buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:9186 Change-Id: I06ad4c4b08a564e177c47fc109261f2f6d303c7b Reviewed-on: https://webrtc-review.googlesource.com/71741 Reviewed-by: Sami Kalliomäki Commit-Queue: Magnus Jedvert Cr-Commit-Position: refs/heads/master@{#22980} --- sdk/android/src/jni/nv12buffer.cc | 2 +- sdk/android/src/jni/nv21buffer.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/android/src/jni/nv12buffer.cc b/sdk/android/src/jni/nv12buffer.cc index 5f7edc85cf..23b1791ef9 100644 --- a/sdk/android/src/jni/nv12buffer.cc +++ b/sdk/android/src/jni/nv12buffer.cc @@ -62,7 +62,7 @@ static void JNI_NV12Buffer_CropAndScale(JNIEnv* jni, // Crop using pointer arithmetic. src_y += crop_x + crop_y * src_stride_y; - src_uv += crop_chroma_x + crop_chroma_y * src_stride_uv; + src_uv += 2 * crop_chroma_x + crop_chroma_y * src_stride_uv; std::vector tmp_buffer(tmp_size); uint8_t* tmp_u = tmp_buffer.data(); diff --git a/sdk/android/src/jni/nv21buffer.cc b/sdk/android/src/jni/nv21buffer.cc index c8a3a8b749..7f11488def 100644 --- a/sdk/android/src/jni/nv21buffer.cc +++ b/sdk/android/src/jni/nv21buffer.cc @@ -63,7 +63,7 @@ static void JNI_NV21Buffer_CropAndScale(JNIEnv* jni, // Crop using pointer arithmetic. src_y += crop_x + crop_y * src_stride_y; - src_uv += crop_chroma_x + crop_chroma_y * src_stride_uv; + src_uv += 2 * crop_chroma_x + crop_chroma_y * src_stride_uv; NV12ToI420Scaler scaler; // U- and V-planes are swapped because this is NV21 not NV12.