Add VideoSink interface to VideoFileRenderer.
Bug: webrtc:8776 Change-Id: I1782b0c197abf6f82a200a2808ddc87d1f250326 Reviewed-on: https://webrtc-review.googlesource.com/41320 Reviewed-by: Anders Carlsson <andersc@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21719}
This commit is contained in:
committed by
Commit Bot
parent
d8f6c167bb
commit
75db552b33
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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 "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "sdk/android/generated_video_jni/jni/VideoFileRenderer_jni.h"
|
||||
#include "sdk/android/src/jni/scoped_java_ref.h"
|
||||
#include "third_party/libyuv/include/libyuv/scale.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static void JNI_VideoFileRenderer_I420Scale(
|
||||
JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
const JavaParamRef<jobject>& j_src_buffer_y,
|
||||
jint j_src_stride_y,
|
||||
const JavaParamRef<jobject>& j_src_buffer_u,
|
||||
jint j_src_stride_u,
|
||||
const JavaParamRef<jobject>& j_src_buffer_v,
|
||||
jint j_src_stride_v,
|
||||
jint width,
|
||||
jint height,
|
||||
const JavaParamRef<jobject>& j_dst_buffer,
|
||||
jint dstWidth,
|
||||
jint dstHeight) {
|
||||
size_t src_size_y = jni->GetDirectBufferCapacity(j_src_buffer_y.obj());
|
||||
size_t src_size_u = jni->GetDirectBufferCapacity(j_src_buffer_u.obj());
|
||||
size_t src_size_v = jni->GetDirectBufferCapacity(j_src_buffer_v.obj());
|
||||
size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer.obj());
|
||||
int dst_stride = dstWidth;
|
||||
RTC_CHECK_GE(src_size_y, j_src_stride_y * height);
|
||||
RTC_CHECK_GE(src_size_u, j_src_stride_u * height / 4);
|
||||
RTC_CHECK_GE(src_size_v, j_src_stride_v * height / 4);
|
||||
RTC_CHECK_GE(dst_size, dst_stride * dstHeight * 3 / 2);
|
||||
uint8_t* src_y = reinterpret_cast<uint8_t*>(
|
||||
jni->GetDirectBufferAddress(j_src_buffer_y.obj()));
|
||||
uint8_t* src_u = reinterpret_cast<uint8_t*>(
|
||||
jni->GetDirectBufferAddress(j_src_buffer_u.obj()));
|
||||
uint8_t* src_v = reinterpret_cast<uint8_t*>(
|
||||
jni->GetDirectBufferAddress(j_src_buffer_v.obj()));
|
||||
uint8_t* dst = reinterpret_cast<uint8_t*>(
|
||||
jni->GetDirectBufferAddress(j_dst_buffer.obj()));
|
||||
|
||||
uint8_t* dst_y = dst;
|
||||
size_t dst_stride_y = dst_stride;
|
||||
uint8_t* dst_u = dst + dst_stride * dstHeight;
|
||||
size_t dst_stride_u = dst_stride / 2;
|
||||
uint8_t* dst_v = dst + dst_stride * dstHeight * 5 / 4;
|
||||
size_t dst_stride_v = dst_stride / 2;
|
||||
|
||||
int ret = libyuv::I420Scale(
|
||||
src_y, j_src_stride_y, src_u, j_src_stride_u, src_v, j_src_stride_v,
|
||||
width, height, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
|
||||
dst_stride_v, dstWidth, dstHeight, libyuv::kFilterBilinear);
|
||||
if (ret) {
|
||||
RTC_LOG(LS_ERROR) << "Error scaling I420 frame: " << ret;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
@ -81,5 +81,41 @@ static void JNI_YuvHelper_I420ToNV12(JNIEnv* jni,
|
||||
width, height);
|
||||
}
|
||||
|
||||
void JNI_YuvHelper_I420Rotate(JNIEnv* jni,
|
||||
const JavaParamRef<jclass>&,
|
||||
const JavaParamRef<jobject>& j_src_y,
|
||||
jint src_stride_y,
|
||||
const JavaParamRef<jobject>& j_src_u,
|
||||
jint src_stride_u,
|
||||
const JavaParamRef<jobject>& j_src_v,
|
||||
jint src_stride_v,
|
||||
const JavaParamRef<jobject>& j_dst_y,
|
||||
jint dst_stride_y,
|
||||
const JavaParamRef<jobject>& j_dst_u,
|
||||
jint dst_stride_u,
|
||||
const JavaParamRef<jobject>& j_dst_v,
|
||||
jint dst_stride_v,
|
||||
jint src_width,
|
||||
jint src_height,
|
||||
jint rotation_mode) {
|
||||
const uint8_t* src_y =
|
||||
static_cast<const uint8_t*>(jni->GetDirectBufferAddress(j_src_y.obj()));
|
||||
const uint8_t* src_u =
|
||||
static_cast<const uint8_t*>(jni->GetDirectBufferAddress(j_src_u.obj()));
|
||||
const uint8_t* src_v =
|
||||
static_cast<const uint8_t*>(jni->GetDirectBufferAddress(j_src_v.obj()));
|
||||
uint8_t* dst_y =
|
||||
static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_y.obj()));
|
||||
uint8_t* dst_u =
|
||||
static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_u.obj()));
|
||||
uint8_t* dst_v =
|
||||
static_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_v.obj()));
|
||||
|
||||
libyuv::I420Rotate(src_y, src_stride_y, src_u, src_stride_u, src_v,
|
||||
src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u,
|
||||
dst_v, dst_stride_v, src_width, src_height,
|
||||
static_cast<libyuv::RotationMode>(rotation_mode));
|
||||
}
|
||||
|
||||
} // namespace jni
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user