nisse 72e735d386 Revert of Delete unused and almost unused frame-related methods. (patchset #12 id:220001 of https://codereview.webrtc.org/2065733003/ )
Reason for revert:
Breaks downstream applications which inherits webrtc::VideoFrameBuffer and tries to override deleted methods data(), stride() and MutableData().

Original issue's description:
> Delete unused and almost unused frame-related methods.
>
> webrtc::VideoFrame::set_video_frame_buffer
> webrtc::VideoFrame::ConvertNativeToI420Frame
>
> cricket::WebRtcVideoFrame::InitToBlack
>
> VideoFrameBuffer::data
> VideoFrameBuffer::stride
> VideoFrameBuffer::MutableData
>
> TBR=tkchin@webrtc.org # Refactoring affecting RTCVideoFrame
> BUG=webrtc:5682
>
> Committed: https://crrev.com/76270de4bc2dac188f10f805e6e2fb86693ef864
> Cr-Commit-Position: refs/heads/master@{#13183}

TBR=perkj@webrtc.org,pbos@webrtc.org,marpan@webrtc.org,tkchin@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5682

Review-Url: https://codereview.webrtc.org/2076113002
Cr-Commit-Position: refs/heads/master@{#13184}
2016-06-17 09:55:23 +00:00

86 lines
2.5 KiB
C++

/*
* Copyright (c) 2012 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 "webrtc/modules/video_processing/spatial_resampler.h"
namespace webrtc {
VPMSimpleSpatialResampler::VPMSimpleSpatialResampler()
: resampling_mode_(kFastRescaling), target_width_(0), target_height_(0) {}
VPMSimpleSpatialResampler::~VPMSimpleSpatialResampler() {}
int32_t VPMSimpleSpatialResampler::SetTargetFrameSize(int32_t width,
int32_t height) {
if (resampling_mode_ == kNoRescaling)
return VPM_OK;
if (width < 1 || height < 1)
return VPM_PARAMETER_ERROR;
target_width_ = width;
target_height_ = height;
return VPM_OK;
}
void VPMSimpleSpatialResampler::SetInputFrameResampleMode(
VideoFrameResampling resampling_mode) {
resampling_mode_ = resampling_mode;
}
void VPMSimpleSpatialResampler::Reset() {
resampling_mode_ = kFastRescaling;
target_width_ = 0;
target_height_ = 0;
}
int32_t VPMSimpleSpatialResampler::ResampleFrame(const VideoFrame& inFrame,
VideoFrame* outFrame) {
// Don't copy if frame remains as is.
if (resampling_mode_ == kNoRescaling) {
return VPM_OK;
// Check if re-sampling is needed
} else if ((inFrame.width() == target_width_) &&
(inFrame.height() == target_height_)) {
return VPM_OK;
}
rtc::scoped_refptr<I420Buffer> scaled_buffer(
buffer_pool_.CreateBuffer(target_width_, target_height_));
scaled_buffer->CropAndScaleFrom(inFrame.video_frame_buffer());
outFrame->set_video_frame_buffer(scaled_buffer);
// Setting time parameters to the output frame.
outFrame->set_timestamp(inFrame.timestamp());
outFrame->set_render_time_ms(inFrame.render_time_ms());
return VPM_OK;
}
int32_t VPMSimpleSpatialResampler::TargetHeight() {
return target_height_;
}
int32_t VPMSimpleSpatialResampler::TargetWidth() {
return target_width_;
}
bool VPMSimpleSpatialResampler::ApplyResample(int32_t width, int32_t height) {
if ((width == target_width_ && height == target_height_) ||
resampling_mode_ == kNoRescaling)
return false;
else
return true;
}
} // namespace webrtc