Update webrtc/media and webrtc/modules to new VideoFrameBuffer interface
TBR=stefan Bug: webrtc:7632 Change-Id: Ifdaf4a591061595a53f677441baad85820336b34 Reviewed-on: https://chromium-review.googlesource.com/530844 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#18591}
This commit is contained in:
parent
3c938fc5ea
commit
7a721e84f8
@ -84,12 +84,14 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
||||
if (!frame || !frame->video_frame_buffer()) {
|
||||
return false;
|
||||
}
|
||||
rtc::scoped_refptr<const webrtc::I420BufferInterface> i420_buffer =
|
||||
frame->video_frame_buffer()->ToI420();
|
||||
// Y
|
||||
int y_width = frame->width();
|
||||
int y_height = frame->height();
|
||||
const uint8_t* y_plane = frame->video_frame_buffer()->DataY();
|
||||
const uint8_t* y_plane = i420_buffer->DataY();
|
||||
const uint8_t* y_pos = y_plane;
|
||||
int32_t y_pitch = frame->video_frame_buffer()->StrideY();
|
||||
int32_t y_pitch = i420_buffer->StrideY();
|
||||
for (int i = 0; i < y_height; ++i) {
|
||||
for (int j = 0; j < y_width; ++j) {
|
||||
uint8_t y_value = *(y_pos + j);
|
||||
@ -100,14 +102,14 @@ class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
||||
y_pos += y_pitch;
|
||||
}
|
||||
// U and V
|
||||
int chroma_width = (frame->width() + 1)/2;
|
||||
int chroma_height = (frame->height() + 1)/2;
|
||||
const uint8_t* u_plane = frame->video_frame_buffer()->DataU();
|
||||
const uint8_t* v_plane = frame->video_frame_buffer()->DataV();
|
||||
int chroma_width = i420_buffer->ChromaWidth();
|
||||
int chroma_height = i420_buffer->ChromaHeight();
|
||||
const uint8_t* u_plane = i420_buffer->DataU();
|
||||
const uint8_t* v_plane = i420_buffer->DataV();
|
||||
const uint8_t* u_pos = u_plane;
|
||||
const uint8_t* v_pos = v_plane;
|
||||
int32_t u_pitch = frame->video_frame_buffer()->StrideU();
|
||||
int32_t v_pitch = frame->video_frame_buffer()->StrideV();
|
||||
int32_t u_pitch = i420_buffer->StrideU();
|
||||
int32_t v_pitch = i420_buffer->StrideV();
|
||||
for (int i = 0; i < chroma_height; ++i) {
|
||||
for (int j = 0; j < chroma_width; ++j) {
|
||||
uint8_t u_value = *(u_pos + j);
|
||||
|
||||
@ -122,7 +122,7 @@ int32_t VideoEncoderSoftwareFallbackWrapper::Encode(
|
||||
int32_t ret = encoder_->Encode(frame, codec_specific_info, frame_types);
|
||||
// If requested, try a software fallback.
|
||||
if (ret == WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE && InitFallbackEncoder()) {
|
||||
if (frame.video_frame_buffer()->native_handle() &&
|
||||
if (frame.video_frame_buffer()->type() == VideoFrameBuffer::Type::kNative &&
|
||||
!fallback_encoder_->SupportsNativeHandle()) {
|
||||
LOG(LS_WARNING) << "Fallback encoder doesn't support native frames, "
|
||||
<< "dropping one frame.";
|
||||
|
||||
@ -125,8 +125,7 @@ class VideoEncoderSoftwareFallbackWrapperTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
void VideoEncoderSoftwareFallbackWrapperTest::EncodeFrame() {
|
||||
rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(
|
||||
kWidth, kHeight, kWidth, (kWidth + 1) / 2, (kWidth + 1) / 2);
|
||||
rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create(kWidth, kHeight);
|
||||
I420Buffer::SetBlack(buffer);
|
||||
std::vector<FrameType> types(1, kVideoFrameKey);
|
||||
|
||||
|
||||
@ -362,15 +362,14 @@ class VideoCaptureExternalTest : public testing::Test {
|
||||
capability.maxFPS = kTestFramerate;
|
||||
capture_callback_.SetExpectedCapability(capability);
|
||||
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer = webrtc::I420Buffer::Create(
|
||||
kTestWidth, kTestHeight,
|
||||
kTestWidth, ((kTestWidth + 1) / 2), (kTestWidth + 1) / 2);
|
||||
rtc::scoped_refptr<webrtc::I420Buffer> buffer =
|
||||
webrtc::I420Buffer::Create(kTestWidth, kTestHeight);
|
||||
|
||||
memset(buffer->MutableDataY(), 127, kTestWidth * kTestHeight);
|
||||
memset(buffer->MutableDataY(), 127, buffer->height() * buffer->StrideY());
|
||||
memset(buffer->MutableDataU(), 127,
|
||||
((kTestWidth + 1) / 2) * ((kTestHeight + 1) / 2));
|
||||
buffer->ChromaHeight() * buffer->StrideU());
|
||||
memset(buffer->MutableDataV(), 127,
|
||||
((kTestWidth + 1) / 2) * ((kTestHeight + 1) / 2));
|
||||
buffer->ChromaHeight() * buffer->StrideV());
|
||||
test_frame_.reset(
|
||||
new webrtc::VideoFrame(buffer, 0, 0, webrtc::kVideoRotation_0));
|
||||
|
||||
|
||||
@ -141,14 +141,14 @@ TEST(VideoDenoiserTest, Denoiser) {
|
||||
VideoDenoiser denoiser_sse_neon(true);
|
||||
|
||||
for (;;) {
|
||||
rtc::scoped_refptr<VideoFrameBuffer> video_frame_buffer(
|
||||
rtc::scoped_refptr<I420BufferInterface> video_frame_buffer(
|
||||
test::ReadI420Buffer(kWidth, kHeight, source_file));
|
||||
if (!video_frame_buffer)
|
||||
break;
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> denoised_frame_c(
|
||||
rtc::scoped_refptr<I420BufferInterface> denoised_frame_c(
|
||||
denoiser_c.DenoiseFrame(video_frame_buffer, false));
|
||||
rtc::scoped_refptr<VideoFrameBuffer> denoised_frame_sse_neon(
|
||||
rtc::scoped_refptr<I420BufferInterface> denoised_frame_sse_neon(
|
||||
denoiser_sse_neon.DenoiseFrame(video_frame_buffer, false));
|
||||
|
||||
// Denoising results should be the same for C and SSE/NEON denoiser.
|
||||
|
||||
@ -72,7 +72,8 @@ VideoDenoiser::VideoDenoiser(bool runtime_cpu_detection)
|
||||
filter_(DenoiserFilter::Create(runtime_cpu_detection, &cpu_type_)),
|
||||
ne_(new NoiseEstimation()) {}
|
||||
|
||||
void VideoDenoiser::DenoiserReset(rtc::scoped_refptr<VideoFrameBuffer> frame) {
|
||||
void VideoDenoiser::DenoiserReset(
|
||||
rtc::scoped_refptr<I420BufferInterface> frame) {
|
||||
width_ = frame->width();
|
||||
height_ = frame->height();
|
||||
mb_cols_ = width_ >> 4;
|
||||
@ -211,8 +212,8 @@ void VideoDenoiser::CopyLumaOnMargin(const uint8_t* y_src,
|
||||
}
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> VideoDenoiser::DenoiseFrame(
|
||||
rtc::scoped_refptr<VideoFrameBuffer> frame,
|
||||
rtc::scoped_refptr<I420BufferInterface> VideoDenoiser::DenoiseFrame(
|
||||
rtc::scoped_refptr<I420BufferInterface> frame,
|
||||
bool noise_estimation_enabled) {
|
||||
// If previous width and height are different from current frame's, need to
|
||||
// reallocate the buffers and no denoising for the current frame.
|
||||
|
||||
@ -24,12 +24,12 @@ class VideoDenoiser {
|
||||
public:
|
||||
explicit VideoDenoiser(bool runtime_cpu_detection);
|
||||
|
||||
rtc::scoped_refptr<VideoFrameBuffer> DenoiseFrame(
|
||||
rtc::scoped_refptr<VideoFrameBuffer> frame,
|
||||
rtc::scoped_refptr<I420BufferInterface> DenoiseFrame(
|
||||
rtc::scoped_refptr<I420BufferInterface> frame,
|
||||
bool noise_estimation_enabled);
|
||||
|
||||
private:
|
||||
void DenoiserReset(rtc::scoped_refptr<VideoFrameBuffer> frame);
|
||||
void DenoiserReset(rtc::scoped_refptr<I420BufferInterface> frame);
|
||||
|
||||
// Check the mb position, return 1: close to the frame center (between 1/8
|
||||
// and 7/8 of width/height), 3: close to the border (out of 1/16 and 15/16
|
||||
@ -76,7 +76,7 @@ class VideoDenoiser {
|
||||
// Save the return values by MbDenoise for each block.
|
||||
std::unique_ptr<DenoiserDecision[]> mb_filter_decision_;
|
||||
I420BufferPool buffer_pool_;
|
||||
rtc::scoped_refptr<VideoFrameBuffer> prev_buffer_;
|
||||
rtc::scoped_refptr<I420BufferInterface> prev_buffer_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user