Delete method webrtc::VideoFrame::allocated_size and enum PlaneType.

BUG=webrtc:5682

Review-Url: https://codereview.webrtc.org/2380623002
Cr-Commit-Position: refs/heads/master@{#14416}
This commit is contained in:
nisse 2016-09-28 03:14:07 -07:00 committed by Commit bot
parent 798896a4aa
commit e5684c5387
8 changed files with 10 additions and 73 deletions

View File

@ -21,12 +21,6 @@ namespace webrtc {
namespace {
int ExpectedSize(int plane_stride, int image_height, PlaneType type) {
if (type == kYPlane)
return plane_stride * image_height;
return plane_stride * ((image_height + 1) / 2);
}
rtc::scoped_refptr<I420Buffer> CreateGradient(int width, int height) {
rtc::scoped_refptr<I420Buffer> buffer(
I420Buffer::Create(width, height));
@ -110,22 +104,6 @@ TEST(TestVideoFrame, WidthHeightValues) {
EXPECT_EQ(789, frame.render_time_ms());
}
TEST(TestVideoFrame, SizeAllocation) {
VideoFrame frame;
frame. CreateEmptyFrame(10, 10, 12, 14, 220);
int height = frame.height();
int stride_y = frame.video_frame_buffer()->StrideY();
int stride_u = frame.video_frame_buffer()->StrideU();
int stride_v = frame.video_frame_buffer()->StrideV();
// Verify that allocated size was computed correctly.
EXPECT_EQ(ExpectedSize(stride_y, height, kYPlane),
frame.allocated_size(kYPlane));
EXPECT_EQ(ExpectedSize(stride_u, height, kUPlane),
frame.allocated_size(kUPlane));
EXPECT_EQ(ExpectedSize(stride_v, height, kVPlane),
frame.allocated_size(kVPlane));
}
TEST(TestVideoFrame, CopyFrame) {
uint32_t timestamp = 1;
int64_t ntp_time_ms = 2;
@ -254,11 +232,6 @@ TEST(TestVideoFrame, CopyBuffer) {
stride_uv, 8, 8));
EXPECT_TRUE(test::EqualPlane(buffer_v, frame2.video_frame_buffer()->DataV(),
stride_uv, 8, 8));
// Compare size.
EXPECT_LE(kSizeY, frame2.allocated_size(kYPlane));
EXPECT_LE(kSizeUv, frame2.allocated_size(kUPlane));
EXPECT_LE(kSizeUv, frame2.allocated_size(kVPlane));
}
TEST(TestVideoFrame, FailToReuseAllocation) {

View File

@ -23,13 +23,6 @@
namespace webrtc {
enum PlaneType {
kYPlane = 0,
kUPlane = 1,
kVPlane = 2,
kNumOfPlanes = 3,
};
// Interface of a simple frame buffer containing pixel data. This interface does
// not contain any frame metadata such as rotation, timestamp, pixel_width, etc.
class VideoFrameBuffer : public rtc::RefCountInterface {

View File

@ -133,28 +133,6 @@ void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) {
rotation_ = videoFrame.rotation_;
}
// TODO(nisse): Delete. Besides test code, only one use, in
// webrtcvideoengine2.cc:CreateBlackFrame.
int VideoFrame::allocated_size(PlaneType type) const {
const int plane_height = (type == kYPlane) ? height() : (height() + 1) / 2;
int stride;
switch (type) {
case kYPlane:
stride = video_frame_buffer_->StrideY();
break;
case kUPlane:
stride = video_frame_buffer_->StrideU();
break;
case kVPlane:
stride = video_frame_buffer_->StrideV();
break;
default:
RTC_NOTREACHED();
return 0;
}
return plane_height * stride;
}
int VideoFrame::width() const {
return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
}

View File

@ -16,10 +16,6 @@
#include "webrtc/media/base/videocommon.h"
#include "webrtc/video_frame.h"
using webrtc::kYPlane;
using webrtc::kUPlane;
using webrtc::kVPlane;
namespace cricket {
WebRtcVideoFrame::WebRtcVideoFrame()

View File

@ -347,11 +347,11 @@ int32_t H264DecoderImpl::Decode(const EncodedImage& input_image,
VideoFrame* video_frame = static_cast<VideoFrame*>(
av_buffer_get_opaque(av_frame_->buf[0]));
RTC_DCHECK(video_frame);
RTC_CHECK_EQ(av_frame_->data[kYPlane],
RTC_CHECK_EQ(av_frame_->data[kYPlaneIndex],
video_frame->video_frame_buffer()->DataY());
RTC_CHECK_EQ(av_frame_->data[kUPlane],
RTC_CHECK_EQ(av_frame_->data[kUPlaneIndex],
video_frame->video_frame_buffer()->DataU());
RTC_CHECK_EQ(av_frame_->data[kVPlane],
RTC_CHECK_EQ(av_frame_->data[kVPlaneIndex],
video_frame->video_frame_buffer()->DataV());
video_frame->set_timestamp(input_image._timeStamp);

View File

@ -49,6 +49,13 @@ void SetExpectedValues3(T value0, T value1, T value2, T* expected_values) {
expected_values[2] = value2;
}
enum PlaneType {
kYPlane = 0,
kUPlane = 1,
kVPlane = 2,
kNumOfPlanes = 3,
};
class Vp8TestEncodedImageCallback : public EncodedImageCallback {
public:
Vp8TestEncodedImageCallback() : picture_id_(-1) {

View File

@ -60,15 +60,12 @@ class FrameGeneratorTest : public ::testing::Test {
// Check that frame is valid, has the correct color and timestamp are clean.
ASSERT_NE(nullptr, frame);
const uint8_t* buffer;
ASSERT_EQ(y_size, frame->allocated_size(PlaneType::kYPlane));
buffer = frame->video_frame_buffer()->DataY();
for (int i = 0; i < y_size; ++i)
ASSERT_EQ(y, buffer[i]);
ASSERT_EQ(uv_size, frame->allocated_size(PlaneType::kUPlane));
buffer = frame->video_frame_buffer()->DataU();
for (int i = 0; i < uv_size; ++i)
ASSERT_EQ(u, buffer[i]);
ASSERT_EQ(uv_size, frame->allocated_size(PlaneType::kVPlane));
buffer = frame->video_frame_buffer()->DataV();
for (int i = 0; i < uv_size; ++i)
ASSERT_EQ(v, buffer[i]);

View File

@ -100,13 +100,6 @@ class VideoFrame {
// to the constructor.
void ShallowCopy(const VideoFrame& videoFrame);
// Get allocated size per plane.
// TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
// webrtc::VideoFrame merge. When used with memset, consider using
// libyuv::I420Rect instead.
int allocated_size(PlaneType type) const;
// Get frame width.
int width() const;