Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: webrtc/sdk/android/src/jni/camera1session_jni.cc

Issue 2984633002: Add a field trial to produce VideoFrames in camera capturers. (Closed)
Patch Set: Update log message. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/sdk/android/src/jni/camera1session_jni.cc
diff --git a/webrtc/sdk/android/src/jni/camera1session_jni.cc b/webrtc/sdk/android/src/jni/camera1session_jni.cc
new file mode 100644
index 0000000000000000000000000000000000000000..34721c40c8bb032f9ea2f2c16960196b66092787
--- /dev/null
+++ b/webrtc/sdk/android/src/jni/camera1session_jni.cc
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <jni.h>
+
+#include "third_party/libyuv/include/libyuv/convert.h"
+#include "webrtc/rtc_base/checks.h"
+#include "webrtc/rtc_base/logging.h"
+
+namespace webrtc_jni {
+
+extern "C" JNIEXPORT void JNICALL
+Java_org_webrtc_Camera1Session_nativeNV21ToI420(JNIEnv* jni,
+ jclass,
+ jint width,
+ jint height,
+ jbyteArray j_src,
+ jobject j_dst) {
+ int dst_stride_y = width;
+ int dst_stride_uv = (width + 1) / 2;
+ int dst_chroma_height = (height + 1) / 2;
+
+ RTC_CHECK_GE(jni->GetArrayLength(j_src), width * height * 3 / 2);
+ RTC_CHECK_GE(jni->GetDirectBufferCapacity(j_dst),
+ dst_stride_y * height + 2 * dst_stride_uv * dst_chroma_height);
+
+ jbyte* src_bytes = jni->GetByteArrayElements(j_src, 0);
+ uint8_t* src_y = reinterpret_cast<uint8_t*>(src_bytes);
+ uint8_t* src_uv = src_y + width * height;
+
+ uint8_t* dst_y = static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst));
+ uint8_t* dst_u = dst_y + dst_stride_y * height;
+ uint8_t* dst_v = dst_u + dst_stride_uv * dst_chroma_height;
+
+ int ret = libyuv::NV21ToI420(src_y, width, src_uv, width, dst_y, dst_stride_y,
magjed_webrtc 2017/07/24 09:51:18 This is a performance regression compared to the e
sakal 2017/08/15 12:41:05 NV21Buffer class should fix this.
+ dst_u, dst_stride_uv, dst_v, dst_stride_uv,
+ width, height);
+ if (ret) {
+ LOG(LS_ERROR) << "Error converting NV21 frame to I420: " << ret;
+ }
+
+ jni->ReleaseByteArrayElements(j_src, src_bytes, 0);
+}
+
+} // namespace webrtc_jni

Powered by Google App Engine
This is Rietveld 408576698