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

Side by Side Diff: webrtc/sdk/android/src/jni/videoframe_jni.cc

Issue 2990583002: Move matrix from VideoFrame to TextureBuffer. (Closed)
Patch Set: Fixes. 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 "libyuv/scale.h"
14
15 #include "webrtc/rtc_base/checks.h"
16
17 namespace webrtc_jni {
18
19 extern "C" JNIEXPORT void JNICALL
20 Java_org_webrtc_VideoFrame_nativeCropAndScaleI420(JNIEnv* jni,
21 jclass,
22 jobject j_src_y,
23 jint src_stride_y,
24 jobject j_src_u,
25 jint src_stride_u,
26 jobject j_src_v,
27 jint src_stride_v,
28 jint crop_x,
29 jint crop_y,
30 jint crop_width,
31 jint crop_height,
32 jobject j_dst_y,
33 jint dst_stride_y,
34 jobject j_dst_u,
35 jint dst_stride_u,
36 jobject j_dst_v,
37 jint dst_stride_v,
38 jint scale_width,
39 jint scale_height) {
40 uint8_t const* src_y =
41 static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_y));
42 uint8_t const* src_u =
43 static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_u));
44 uint8_t const* src_v =
45 static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_v));
46 uint8_t* dst_y = static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_y));
47 uint8_t* dst_u = static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_u));
48 uint8_t* dst_v = static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_v));
49
50 // Perform cropping using pointer arithmetic.
51 src_y += crop_x + crop_y * src_stride_y;
52 src_u += crop_x / 2 + crop_y / 2 * src_stride_u;
53 src_v += crop_x / 2 + crop_y / 2 * src_stride_v;
54
55 bool ret = libyuv::I420Scale(
56 src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, crop_width,
57 crop_height, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
58 dst_stride_v, scale_width, scale_height, libyuv::kFilterBox);
59 RTC_DCHECK_EQ(ret, 0) << "I420Scale failed";
60 }
61
62 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698