Delete remnants of non-square pixel support from cricket::VideoFrame.

If ever needed, add some aspect ratio parameter, without pixel_width
and pixel_height arguments cluttering commonly used functions.

BUG=webrtc:5426

Review URL: https://codereview.webrtc.org/1586613002

Cr-Commit-Position: refs/heads/master@{#11243}
This commit is contained in:
nisse
2016-01-13 23:43:52 -08:00
committed by Commit bot
parent beed8280d8
commit 709513d413
7 changed files with 37 additions and 84 deletions

View File

@ -82,7 +82,7 @@ TEST_F(VideoTrackTest, RenderVideo) {
ASSERT_FALSE(renderer_input == NULL);
cricket::WebRtcVideoFrame frame;
frame.InitToBlack(123, 123, 1, 1, 0);
frame.InitToBlack(123, 123, 0);
renderer_input->RenderFrame(&frame);
EXPECT_EQ(1, renderer_1->num_rendered_frames());

View File

@ -220,7 +220,6 @@ VideoFrame* VideoFrame::Stretch(size_t dst_width, size_t dst_height,
bool interpolate, bool vert_crop) const {
VideoFrame* dest = CreateEmptyFrame(static_cast<int>(dst_width),
static_cast<int>(dst_height),
GetPixelWidth(), GetPixelHeight(),
GetTimeStamp());
if (dest) {
StretchToFrame(dest, interpolate, vert_crop);

View File

@ -41,8 +41,7 @@ class VideoFrame {
VideoFrame() {}
virtual ~VideoFrame() {}
virtual bool InitToBlack(int w, int h, size_t pixel_width,
size_t pixel_height, int64_t time_stamp) = 0;
virtual bool InitToBlack(int w, int h, int64_t time_stamp) = 0;
// Creates a frame from a raw sample with FourCC |format| and size |w| x |h|.
// |h| can be negative indicating a vertically flipped image.
// |dw| is destination width; can be less than |w| if cropping is desired.
@ -56,8 +55,6 @@ class VideoFrame {
int dh,
uint8_t* sample,
size_t sample_size,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp,
webrtc::VideoRotation rotation,
bool apply_rotation) = 0;
@ -92,11 +89,6 @@ class VideoFrame {
virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
const = 0;
// For retrieving the aspect ratio of each pixel. Usually this is 1x1, but
// the aspect_ratio_idc parameter of H.264 can specify non-square pixels.
virtual size_t GetPixelWidth() const = 0;
virtual size_t GetPixelHeight() const = 0;
virtual int64_t GetTimeStamp() const = 0;
virtual void SetTimeStamp(int64_t time_stamp) = 0;
@ -209,8 +201,7 @@ class VideoFrame {
protected:
// Creates an empty frame.
virtual VideoFrame *CreateEmptyFrame(int w, int h, size_t pixel_width,
size_t pixel_height,
virtual VideoFrame *CreateEmptyFrame(int w, int h,
int64_t time_stamp) const = 0;
virtual void SetRotation(webrtc::VideoRotation rotation) = 0;
};

View File

@ -152,7 +152,7 @@ class VideoFrameTest : public testing::Test {
bool ret = false;
for (int i = 0; i < repeat_; ++i) {
ret = frame->Init(format, width, height, dw, dh,
sample, sample_size, 1, 1, 0, rotation);
sample, sample_size, 0, rotation);
}
return ret;
}
@ -295,7 +295,7 @@ class VideoFrameTest : public testing::Test {
const uint8_t* start = reinterpret_cast<const uint8_t*>(ms->GetBuffer());
int awidth = (width + 1) & ~1;
frame->InitToBlack(width, height, 1, 1, 0);
frame->InitToBlack(width, height, 0);
int stride_y = frame->GetYPitch();
int stride_u = frame->GetUPitch();
int stride_v = frame->GetVPitch();
@ -339,7 +339,7 @@ class VideoFrameTest : public testing::Test {
start = start + pitch * (height - 1);
pitch = -pitch;
}
frame->InitToBlack(width, height, 1, 1, 0);
frame->InitToBlack(width, height, 0);
int stride_y = frame->GetYPitch();
int stride_u = frame->GetUPitch();
int stride_v = frame->GetVPitch();
@ -465,8 +465,6 @@ class VideoFrameTest : public testing::Test {
static bool IsEqual(const cricket::VideoFrame& frame,
size_t width,
size_t height,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp,
const uint8_t* y,
uint32_t ypitch,
@ -477,8 +475,6 @@ class VideoFrameTest : public testing::Test {
int max_error) {
return IsSize(frame, static_cast<uint32_t>(width),
static_cast<uint32_t>(height)) &&
frame.GetPixelWidth() == pixel_width &&
frame.GetPixelHeight() == pixel_height &&
frame.GetTimeStamp() == time_stamp &&
IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch,
static_cast<uint32_t>(width),
@ -496,7 +492,6 @@ class VideoFrameTest : public testing::Test {
int max_error) {
return IsEqual(frame1,
frame2.GetWidth(), frame2.GetHeight(),
frame2.GetPixelWidth(), frame2.GetPixelHeight(),
frame2.GetTimeStamp(),
frame2.GetYPlane(), frame2.GetYPitch(),
frame2.GetUPlane(), frame2.GetUPitch(),
@ -512,7 +507,6 @@ class VideoFrameTest : public testing::Test {
IsEqual(frame1,
frame2.GetWidth() - hcrop * 2,
frame2.GetHeight() - vcrop * 2,
frame2.GetPixelWidth(), frame2.GetPixelHeight(),
frame2.GetTimeStamp(),
frame2.GetYPlane() + vcrop * frame2.GetYPitch()
+ hcrop,
@ -549,7 +543,7 @@ class VideoFrameTest : public testing::Test {
const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
const uint8_t* u = y + kWidth * kHeight;
const uint8_t* v = u + kWidth * kHeight / 4;
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, y, kWidth, u,
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 0, y, kWidth, u,
kWidth / 2, v, kWidth / 2, 0));
}
@ -564,7 +558,7 @@ class VideoFrameTest : public testing::Test {
const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
const uint8_t* v = y + kWidth * kHeight;
const uint8_t* u = v + kWidth * kHeight / 4;
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 1, 1, 0, y, kWidth, u,
EXPECT_TRUE(IsEqual(frame, kWidth, kHeight, 0, y, kWidth, u,
kWidth / 2, v, kWidth / 2, 0));
}
@ -828,10 +822,10 @@ class VideoFrameTest : public testing::Test {
EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \
kHeight, \
reinterpret_cast<uint8_t*>(ms->GetBuffer()), \
data_size, 1, 1, 0, webrtc::kVideoRotation_0)); \
data_size, 0, webrtc::kVideoRotation_0)); \
int width_rotate = static_cast<int>(frame1.GetWidth()); \
int height_rotate = static_cast<int>(frame1.GetHeight()); \
EXPECT_TRUE(frame3.InitToBlack(width_rotate, height_rotate, 1, 1, 0)); \
EXPECT_TRUE(frame3.InitToBlack(width_rotate, height_rotate, 0)); \
libyuv::I420Mirror( \
frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \
frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \
@ -859,10 +853,10 @@ class VideoFrameTest : public testing::Test {
EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \
kHeight, \
reinterpret_cast<uint8_t*>(ms->GetBuffer()), \
data_size, 1, 1, 0, webrtc::kVideoRotation_0)); \
data_size, 0, webrtc::kVideoRotation_0)); \
int width_rotate = static_cast<int>(frame1.GetWidth()); \
int height_rotate = static_cast<int>(frame1.GetHeight()); \
EXPECT_TRUE(frame3.InitToBlack(width_rotate, height_rotate, 1, 1, 0)); \
EXPECT_TRUE(frame3.InitToBlack(width_rotate, height_rotate, 0)); \
libyuv::I420Rotate( \
frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \
frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \
@ -968,12 +962,12 @@ class VideoFrameTest : public testing::Test {
uint8_t pixel[3] = {1, 2, 3};
for (int i = 0; i < repeat_; ++i) {
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
sizeof(pixel), 1, 1, 0, webrtc::kVideoRotation_0));
sizeof(pixel), 0, webrtc::kVideoRotation_0));
}
const uint8_t* y = pixel;
const uint8_t* u = y + 1;
const uint8_t* v = u + 1;
EXPECT_TRUE(IsEqual(frame, 1, 1, 1, 1, 0, y, 1, u, 1, v, 1, 0));
EXPECT_TRUE(IsEqual(frame, 1, 1, 0, y, 1, u, 1, v, 1, 0));
}
// Test 5 pixel edge case image.
@ -983,7 +977,7 @@ class VideoFrameTest : public testing::Test {
memset(pixels5x5, 1, 5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2);
for (int i = 0; i < repeat_; ++i) {
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, pixels5x5,
sizeof(pixels5x5), 1, 1, 0,
sizeof(pixels5x5), 0,
webrtc::kVideoRotation_0));
}
EXPECT_EQ(5u, frame.GetWidth());
@ -999,7 +993,7 @@ class VideoFrameTest : public testing::Test {
uint8_t pixel[4] = {64, 128, 192, 255};
for (int i = 0; i < repeat_; ++i) {
EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, pixel,
sizeof(pixel), 1, 1, 0,
sizeof(pixel), 0,
webrtc::kVideoRotation_0));
}
// Convert back to ARGB.
@ -1349,7 +1343,7 @@ class VideoFrameTest : public testing::Test {
void ConstructBlack() {
T frame;
for (int i = 0; i < repeat_; ++i) {
EXPECT_TRUE(frame.InitToBlack(kWidth, kHeight, 1, 1, 0));
EXPECT_TRUE(frame.InitToBlack(kWidth, kHeight, 0));
}
EXPECT_TRUE(IsSize(frame, kWidth, kHeight));
EXPECT_TRUE(IsBlack(frame));
@ -1415,14 +1409,14 @@ class VideoFrameTest : public testing::Test {
ASSERT_TRUE(ms.get() != NULL);
size_t data_size;
ms->GetSize(&data_size);
EXPECT_TRUE(frame1.InitToBlack(kWidth, kHeight, 1, 1, 0));
EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 1, 1, 0));
EXPECT_TRUE(frame1.InitToBlack(kWidth, kHeight, 0));
EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 0));
EXPECT_TRUE(IsBlack(frame1));
EXPECT_TRUE(IsEqual(frame1, frame2, 0));
EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth,
kHeight,
reinterpret_cast<uint8_t*>(ms->GetBuffer()),
data_size, 1, 1, 0, rotation, apply_rotation));
data_size, 0, rotation, apply_rotation));
if (apply_rotation)
EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation());
else
@ -1494,7 +1488,7 @@ class VideoFrameTest : public testing::Test {
out,
out_size, stride));
}
EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 1, 1, 0));
EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 0));
for (int i = 0; i < repeat_from; ++i) {
EXPECT_EQ(0, RGBToI420(out, stride,
frame2.GetYPlane(), frame2.GetYPitch(),
@ -1915,7 +1909,7 @@ class VideoFrameTest : public testing::Test {
uint8_t pixel[3] = {1, 2, 3};
T frame;
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
sizeof(pixel), 1, 1, 0,
sizeof(pixel), 0,
webrtc::kVideoRotation_0));
for (int i = 0; i < repeat_; ++i) {
EXPECT_EQ(out_size, frame.CopyToBuffer(out.get(), out_size));
@ -1929,7 +1923,7 @@ class VideoFrameTest : public testing::Test {
void StretchToFrame() {
// Create the source frame as a black frame.
T source;
EXPECT_TRUE(source.InitToBlack(kWidth * 2, kHeight * 2, 1, 1, 0));
EXPECT_TRUE(source.InitToBlack(kWidth * 2, kHeight * 2, 0));
EXPECT_TRUE(IsSize(source, kWidth * 2, kHeight * 2));
// Create the target frame by loading from a file.

View File

@ -40,8 +40,6 @@ using webrtc::kVPlane;
namespace cricket {
WebRtcVideoFrame::WebRtcVideoFrame():
pixel_width_(0),
pixel_height_(0),
time_stamp_ns_(0),
rotation_(webrtc::kVideoRotation_0) {}
@ -50,8 +48,6 @@ WebRtcVideoFrame::WebRtcVideoFrame(
int64_t time_stamp_ns,
webrtc::VideoRotation rotation)
: video_frame_buffer_(buffer),
pixel_width_(1),
pixel_height_(1),
time_stamp_ns_(time_stamp_ns),
rotation_(rotation) {
}
@ -65,12 +61,10 @@ bool WebRtcVideoFrame::Init(uint32_t format,
int dh,
uint8_t* sample,
size_t sample_size,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation) {
return Reset(format, w, h, dw, dh, sample, sample_size, pixel_width,
pixel_height, time_stamp_ns, rotation,
return Reset(format, w, h, dw, dh, sample, sample_size,
time_stamp_ns, rotation,
true /*apply_rotation*/);
}
@ -78,13 +72,13 @@ bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh,
bool apply_rotation) {
return Reset(frame->fourcc, frame->width, frame->height, dw, dh,
static_cast<uint8_t*>(frame->data), frame->data_size,
frame->pixel_width, frame->pixel_height, frame->time_stamp,
frame->time_stamp,
frame->rotation, apply_rotation);
}
bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width,
size_t pixel_height, int64_t time_stamp_ns) {
InitToEmptyBuffer(w, h, pixel_width, pixel_height, time_stamp_ns);
bool WebRtcVideoFrame::InitToBlack(int w, int h,
int64_t time_stamp_ns) {
InitToEmptyBuffer(w, h, time_stamp_ns);
return SetToBlack();
}
@ -151,8 +145,6 @@ WebRtcVideoFrame::GetVideoFrameBuffer() const {
VideoFrame* WebRtcVideoFrame::Copy() const {
WebRtcVideoFrame* new_frame = new WebRtcVideoFrame(
video_frame_buffer_, time_stamp_ns_, rotation_);
new_frame->pixel_width_ = pixel_width_;
new_frame->pixel_height_ = pixel_height_;
return new_frame;
}
@ -196,8 +188,6 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
int dh,
uint8_t* sample,
size_t sample_size,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation,
bool apply_rotation) {
@ -217,7 +207,7 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
new_height = dw;
}
InitToEmptyBuffer(new_width, new_height, pixel_width, pixel_height,
InitToEmptyBuffer(new_width, new_height,
time_stamp_ns);
rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
@ -247,19 +237,16 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
}
VideoFrame* WebRtcVideoFrame::CreateEmptyFrame(
int w, int h, size_t pixel_width, size_t pixel_height,
int w, int h,
int64_t time_stamp_ns) const {
WebRtcVideoFrame* frame = new WebRtcVideoFrame();
frame->InitToEmptyBuffer(w, h, pixel_width, pixel_height, time_stamp_ns);
frame->InitToEmptyBuffer(w, h, time_stamp_ns);
return frame;
}
void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h, size_t pixel_width,
size_t pixel_height,
void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h,
int64_t time_stamp_ns) {
video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
pixel_width_ = pixel_width;
pixel_height_ = pixel_height;
time_stamp_ns_ = time_stamp_ns;
rotation_ = webrtc::kVideoRotation_0;
}
@ -292,7 +279,6 @@ const VideoFrame* WebRtcVideoFrame::GetCopyWithRotationApplied() const {
}
rotated_frame_.reset(CreateEmptyFrame(rotated_width, rotated_height,
GetPixelWidth(), GetPixelHeight(),
GetTimeStamp()));
// TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from

View File

@ -59,18 +59,14 @@ class WebRtcVideoFrame : public VideoFrame {
int dh,
uint8_t* sample,
size_t sample_size,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation);
bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_rotation);
void InitToEmptyBuffer(int w, int h, size_t pixel_width, size_t pixel_height,
int64_t time_stamp_ns);
void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height,
int64_t time_stamp_ns) override;
bool InitToBlack(int w, int h, int64_t time_stamp_ns) override;
// From base class VideoFrame.
bool Reset(uint32_t format,
@ -80,8 +76,6 @@ class WebRtcVideoFrame : public VideoFrame {
int dh,
uint8_t* sample,
size_t sample_size,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation,
bool apply_rotation) override;
@ -101,8 +95,6 @@ class WebRtcVideoFrame : public VideoFrame {
rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
const override;
size_t GetPixelWidth() const override { return pixel_width_; }
size_t GetPixelHeight() const override { return pixel_height_; }
int64_t GetTimeStamp() const override { return time_stamp_ns_; }
void SetTimeStamp(int64_t time_stamp_ns) override {
time_stamp_ns_ = time_stamp_ns;
@ -128,14 +120,11 @@ class WebRtcVideoFrame : public VideoFrame {
}
private:
VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width,
size_t pixel_height,
VideoFrame* CreateEmptyFrame(int w, int h,
int64_t time_stamp_ns) const override;
// An opaque reference counted handle that stores the pixel data.
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
size_t pixel_width_;
size_t pixel_height_;
int64_t time_stamp_ns_;
webrtc::VideoRotation rotation_;

View File

@ -39,11 +39,9 @@ class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame {
virtual VideoFrame* CreateEmptyFrame(int w,
int h,
size_t pixel_width,
size_t pixel_height,
int64_t time_stamp) const override {
WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame();
frame->InitToBlack(w, h, pixel_width, pixel_height, time_stamp);
frame->InitToBlack(w, h, time_stamp);
return frame;
}
};
@ -64,8 +62,6 @@ class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
// Build the CapturedFrame.
cricket::CapturedFrame captured_frame;
captured_frame.fourcc = cricket::FOURCC_I420;
captured_frame.pixel_width = 1;
captured_frame.pixel_height = 1;
captured_frame.time_stamp = 5678;
captured_frame.rotation = frame_rotation;
captured_frame.width = frame_width;
@ -85,8 +81,6 @@ class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
apply_rotation));
// Verify the new frame.
EXPECT_EQ(1u, frame.GetPixelWidth());
EXPECT_EQ(1u, frame.GetPixelHeight());
EXPECT_EQ(5678, frame.GetTimeStamp());
if (apply_rotation)
EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation());