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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <jni.h>
12
13 #include "third_party/libyuv/include/libyuv/convert.h"
14 #include "webrtc/rtc_base/checks.h"
15 #include "webrtc/rtc_base/logging.h"
16
17 namespace webrtc_jni {
18
19 extern "C" JNIEXPORT void JNICALL
20 Java_org_webrtc_Camera1Session_nativeNV21ToI420(JNIEnv* jni,
21 jclass,
22 jint width,
23 jint height,
24 jbyteArray j_src,
25 jobject j_dst) {
26 int dst_stride_y = width;
27 int dst_stride_uv = (width + 1) / 2;
28 int dst_chroma_height = (height + 1) / 2;
29
30 RTC_CHECK_GE(jni->GetArrayLength(j_src), width * height * 3 / 2);
31 RTC_CHECK_GE(jni->GetDirectBufferCapacity(j_dst),
32 dst_stride_y * height + 2 * dst_stride_uv * dst_chroma_height);
33
34 jbyte* src_bytes = jni->GetByteArrayElements(j_src, 0);
35 uint8_t* src_y = reinterpret_cast<uint8_t*>(src_bytes);
36 uint8_t* src_uv = src_y + width * height;
37
38 uint8_t* dst_y = static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst));
39 uint8_t* dst_u = dst_y + dst_stride_y * height;
40 uint8_t* dst_v = dst_u + dst_stride_uv * dst_chroma_height;
41
42 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.
43 dst_u, dst_stride_uv, dst_v, dst_stride_uv,
44 width, height);
45 if (ret) {
46 LOG(LS_ERROR) << "Error converting NV21 frame to I420: " << ret;
47 }
48
49 jni->ReleaseByteArrayElements(j_src, src_bytes, 0);
50 }
51
52 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698