Delete webrtc::VideoFrame::CreateEmptyFrame.

BUG=webrtc:5682

Review-Url: https://codereview.webrtc.org/2378003002
Cr-Commit-Position: refs/heads/master@{#14512}
This commit is contained in:
nisse 2016-10-04 23:27:30 -07:00 committed by Commit bot
parent 91e1a1abef
commit f122a85287
8 changed files with 26 additions and 97 deletions

View File

@ -91,23 +91,20 @@ TEST(TestVideoFrame, CopiesInitialFrameWithoutCrashing) {
}
TEST(TestVideoFrame, WidthHeightValues) {
VideoFrame frame;
VideoFrame frame(I420Buffer::Create(10, 10, 10, 14, 90),
webrtc::kVideoRotation_0,
789 * rtc::kNumMicrosecsPerMillisec);
const int valid_value = 10;
frame.CreateEmptyFrame(10, 10, 10, 14, 90);
EXPECT_EQ(valid_value, frame.width());
EXPECT_EQ(valid_value, frame.height());
frame.set_timestamp(123u);
EXPECT_EQ(123u, frame.timestamp());
frame.set_ntp_time_ms(456);
EXPECT_EQ(456, frame.ntp_time_ms());
frame.set_render_time_ms(789);
EXPECT_EQ(789, frame.render_time_ms());
}
TEST(TestVideoFrame, CopyFrame) {
uint32_t timestamp = 1;
int64_t ntp_time_ms = 2;
int64_t render_time_ms = 3;
int stride_y = 15;
int stride_u = 10;
int stride_v = 10;
@ -115,11 +112,6 @@ TEST(TestVideoFrame, CopyFrame) {
int height = 15;
// Copy frame.
VideoFrame small_frame;
small_frame.CreateEmptyFrame(width, height,
stride_y, stride_u, stride_v);
small_frame.set_timestamp(timestamp);
small_frame.set_ntp_time_ms(ntp_time_ms);
small_frame.set_render_time_ms(render_time_ms);
const int kSizeY = 400;
const int kSizeU = 100;
const int kSizeV = 100;
@ -214,8 +206,7 @@ TEST(TestVideoFrame, CopyBuffer) {
int stride_uv = 10;
const int kSizeY = 225;
const int kSizeUv = 80;
frame2.CreateEmptyFrame(width, height,
stride_y, stride_uv, stride_uv);
uint8_t buffer_y[kSizeY];
uint8_t buffer_u[kSizeUv];
uint8_t buffer_v[kSizeUv];
@ -234,20 +225,6 @@ TEST(TestVideoFrame, CopyBuffer) {
stride_uv, 8, 8));
}
TEST(TestVideoFrame, FailToReuseAllocation) {
VideoFrame frame1;
frame1.CreateEmptyFrame(640, 320, 640, 320, 320);
const uint8_t* y = frame1.video_frame_buffer()->DataY();
const uint8_t* u = frame1.video_frame_buffer()->DataU();
const uint8_t* v = frame1.video_frame_buffer()->DataV();
// Make a shallow copy of |frame1|.
VideoFrame frame2(frame1.video_frame_buffer(), 0, 0, kVideoRotation_0);
frame1.CreateEmptyFrame(640, 320, 640, 320, 320);
EXPECT_NE(y, frame1.video_frame_buffer()->DataY());
EXPECT_NE(u, frame1.video_frame_buffer()->DataU());
EXPECT_NE(v, frame1.video_frame_buffer()->DataV());
}
TEST(TestVideoFrame, TextureInitialValues) {
test::FakeNativeHandle* handle = new test::FakeNativeHandle();
VideoFrame frame = test::FakeNativeHandle::CreateFrame(

View File

@ -51,29 +51,6 @@ VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
RTC_DCHECK(buffer);
}
void VideoFrame::CreateEmptyFrame(int width,
int height,
int stride_y,
int stride_u,
int stride_v) {
const int half_width = (width + 1) / 2;
RTC_DCHECK_GT(width, 0);
RTC_DCHECK_GT(height, 0);
RTC_DCHECK_GE(stride_y, width);
RTC_DCHECK_GE(stride_u, half_width);
RTC_DCHECK_GE(stride_v, half_width);
// Creating empty frame - reset all values.
timestamp_rtp_ = 0;
ntp_time_ms_ = 0;
timestamp_us_ = 0;
rotation_ = kVideoRotation_0;
// Allocate a new buffer.
video_frame_buffer_ = I420Buffer::Create(
width, height, stride_y, stride_u, stride_v);
}
void VideoFrame::CreateFrame(const uint8_t* buffer_y,
const uint8_t* buffer_u,
const uint8_t* buffer_v,

View File

@ -74,9 +74,8 @@ class EmptyFrameGenerator : public FrameGenerator {
public:
EmptyFrameGenerator(int width, int height) : width_(width), height_(height) {}
VideoFrame* NextFrame() override {
frame_.reset(new VideoFrame());
frame_->CreateEmptyFrame(width_, height_, width_, (width_ + 1) / 2,
(width_ + 1) / 2);
frame_.reset(new VideoFrame(I420Buffer::Create(width_, height_),
webrtc::kVideoRotation_0, 0));
return frame_.get();
}

View File

@ -20,13 +20,6 @@ FakeDecoder::FakeDecoder() : callback_(NULL) {}
int32_t FakeDecoder::InitDecode(const VideoCodec* config,
int32_t number_of_cores) {
config_ = *config;
size_t width = config->width;
size_t height = config->height;
frame_.CreateEmptyFrame(static_cast<int>(width),
static_cast<int>(height),
static_cast<int>(width),
static_cast<int>((width + 1) / 2),
static_cast<int>((width + 1) / 2));
return WEBRTC_VIDEO_CODEC_OK;
}
@ -35,11 +28,13 @@ int32_t FakeDecoder::Decode(const EncodedImage& input,
const RTPFragmentationHeader* fragmentation,
const CodecSpecificInfo* codec_specific_info,
int64_t render_time_ms) {
frame_.set_timestamp(input._timeStamp);
frame_.set_ntp_time_ms(input.ntp_time_ms_);
frame_.set_render_time_ms(render_time_ms);
VideoFrame frame(I420Buffer::Create(config_.width, config_.height),
webrtc::kVideoRotation_0,
render_time_ms * rtc::kNumMicrosecsPerMillisec);
frame.set_timestamp(input._timeStamp);
frame.set_ntp_time_ms(input.ntp_time_ms_);
callback_->Decoded(frame_);
callback_->Decoded(frame);
return WEBRTC_VIDEO_CODEC_OK;
}

View File

@ -44,7 +44,6 @@ class FakeDecoder : public VideoDecoder {
private:
VideoCodec config_;
VideoFrame frame_;
DecodedImageCallback* callback_;
};

View File

@ -154,6 +154,8 @@ class ScrollingImageFrameGenerator : public FrameGenerator {
scroll_time_(scroll_time_ms),
pause_time_(pause_time_ms),
num_frames_(files.size()),
target_width_(static_cast<int>(target_width)),
target_height_(static_cast<int>(target_height)),
current_frame_num_(num_frames_ - 1),
current_source_frame_(nullptr),
file_generator_(files, source_width, source_height, 1) {
@ -164,11 +166,6 @@ class ScrollingImageFrameGenerator : public FrameGenerator {
RTC_DCHECK_GE(scroll_time_ms, 0);
RTC_DCHECK_GE(pause_time_ms, 0);
RTC_DCHECK_GT(scroll_time_ms + pause_time_ms, 0);
current_frame_.CreateEmptyFrame(static_cast<int>(target_width),
static_cast<int>(target_height),
static_cast<int>(target_width),
static_cast<int>((target_width + 1) / 2),
static_cast<int>((target_width + 1) / 2));
}
virtual ~ScrollingImageFrameGenerator() {}
@ -202,12 +199,10 @@ class ScrollingImageFrameGenerator : public FrameGenerator {
}
void CropSourceToScrolledImage(double scroll_factor) {
const int kTargetWidth = current_frame_.width();
const int kTargetHeight = current_frame_.height();
int scroll_margin_x = current_source_frame_->width() - kTargetWidth;
int scroll_margin_x = current_source_frame_->width() - target_width_;
int pixels_scrolled_x =
static_cast<int>(scroll_margin_x * scroll_factor + 0.5);
int scroll_margin_y = current_source_frame_->height() - kTargetHeight;
int scroll_margin_y = current_source_frame_->height() - target_height_;
int pixels_scrolled_y =
static_cast<int>(scroll_margin_y * scroll_factor + 0.5);
@ -225,7 +220,7 @@ class ScrollingImageFrameGenerator : public FrameGenerator {
&current_source_frame_->video_frame_buffer()->DataY()[offset_y],
&current_source_frame_->video_frame_buffer()->DataU()[offset_u],
&current_source_frame_->video_frame_buffer()->DataV()[offset_v],
kTargetWidth, kTargetHeight,
target_width_, target_height_,
current_source_frame_->video_frame_buffer()->StrideY(),
current_source_frame_->video_frame_buffer()->StrideU(),
current_source_frame_->video_frame_buffer()->StrideV(),
@ -237,6 +232,9 @@ class ScrollingImageFrameGenerator : public FrameGenerator {
const int64_t scroll_time_;
const int64_t pause_time_;
const size_t num_frames_;
const int target_width_;
const int target_height_;
size_t current_frame_num_;
VideoFrame* current_source_frame_;
VideoFrame current_frame_;

View File

@ -99,8 +99,8 @@ class OveruseFrameDetectorTest : public ::testing::Test,
int width,
int height,
int delay_ms) {
VideoFrame frame;
frame.CreateEmptyFrame(width, height, width, width / 2, width / 2);
VideoFrame frame(I420Buffer::Create(width, height),
webrtc::kVideoRotation_0, 0);
uint32_t timestamp = 0;
while (num_frames-- > 0) {
frame.set_timestamp(timestamp);
@ -281,8 +281,8 @@ TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) {
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(testing::AtLeast(1));
static const int kIntervalMs = 33;
static const size_t kNumFramesEncodingDelay = 3;
VideoFrame frame;
frame.CreateEmptyFrame(kWidth, kHeight, kWidth, kWidth / 2, kWidth / 2);
VideoFrame frame(I420Buffer::Create(kWidth, kHeight),
webrtc::kVideoRotation_0, 0);
for (size_t i = 0; i < 1000; ++i) {
// Unique timestamps.
frame.set_timestamp(static_cast<uint32_t>(i));
@ -302,8 +302,8 @@ TEST_F(OveruseFrameDetectorTest, UpdatesExistingSamples) {
EXPECT_CALL(*(observer_.get()), OveruseDetected()).Times(testing::AtLeast(1));
static const int kIntervalMs = 33;
static const int kDelayMs = 30;
VideoFrame frame;
frame.CreateEmptyFrame(kWidth, kHeight, kWidth, kWidth / 2, kWidth / 2);
VideoFrame frame(I420Buffer::Create(kWidth, kHeight),
webrtc::kVideoRotation_0, 0);
uint32_t timestamp = 0;
for (size_t i = 0; i < 1000; ++i) {
frame.set_timestamp(timestamp);

View File

@ -44,22 +44,6 @@ class VideoFrame {
int64_t render_time_ms,
VideoRotation rotation);
// CreateEmptyFrame: Sets frame dimensions and allocates buffers based
// on set dimensions - height and plane stride.
// If required size is bigger than the allocated one, new buffers of adequate
// size will be allocated.
// TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
// webrtc::VideoFrame merge. If you need to write into the frame, create a
// VideoFrameBuffer of the desired size, e.g, using I420Buffer::Create and
// write to that. And if you need to wrap it into a VideoFrame, pass it to the
// constructor.
void CreateEmptyFrame(int width,
int height,
int stride_y,
int stride_u,
int stride_v);
// CreateFrame: Sets the frame's members and buffers. If required size is
// bigger than allocated one, new buffers of adequate size will be allocated.