From fae14804ee553cc6aa5de594eafe234f32e16bfd Mon Sep 17 00:00:00 2001 From: Magnus Jedvert Date: Thu, 7 Apr 2016 09:26:41 +0200 Subject: [PATCH] Android: Fix chroma sampling bug when converting from texture to YUV The xUnit for the UV channels in SurfaceTextureHelper.YuvConverter is currently calculated from 1 / (2 * width). It should be 1 / (width / 2) instead. R=nisse@webrtc.org Review URL: https://codereview.webrtc.org/1862003002 . Cr-Commit-Position: refs/heads/master@{#12274} --- .../api/java/android/org/webrtc/SurfaceTextureHelper.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java b/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java index 4d75d6891d..5a54e904ad 100644 --- a/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java +++ b/webrtc/api/java/android/org/webrtc/SurfaceTextureHelper.java @@ -251,10 +251,10 @@ class SurfaceTextureHelper { // Draw U GLES20.glViewport(0, height, uv_width, uv_height); - // Matrix * (1;0;0;0) / (2*width). Note that opengl uses column major order. + // Matrix * (1;0;0;0) / (width / 2). Note that opengl uses column major order. GLES20.glUniform2f(xUnitLoc, - transformMatrix[0] / (2.0f*width), - transformMatrix[1] / (2.0f*width)); + 2.0f * transformMatrix[0] / width, + 2.0f * transformMatrix[1] / width); GLES20.glUniform4f(coeffsLoc, -0.169f, -0.331f, 0.499f, 0.5f); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);