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 Committed: https://crrev.com/709513d4133107d5c02aed34a5ee99444c4d4e25 Cr-Commit-Position: refs/heads/master@{#11243} Review URL: https://codereview.webrtc.org/1586613002 Cr-Commit-Position: refs/heads/master@{#11287}
This commit is contained in:
parent
33c1dca48b
commit
8b1e431231
@ -82,7 +82,7 @@ TEST_F(VideoTrackTest, RenderVideo) {
|
|||||||
ASSERT_FALSE(renderer_input == NULL);
|
ASSERT_FALSE(renderer_input == NULL);
|
||||||
|
|
||||||
cricket::WebRtcVideoFrame frame;
|
cricket::WebRtcVideoFrame frame;
|
||||||
frame.InitToBlack(123, 123, 1, 1, 0);
|
frame.InitToBlack(123, 123, 0);
|
||||||
renderer_input->RenderFrame(&frame);
|
renderer_input->RenderFrame(&frame);
|
||||||
EXPECT_EQ(1, renderer_1->num_rendered_frames());
|
EXPECT_EQ(1, renderer_1->num_rendered_frames());
|
||||||
|
|
||||||
|
|||||||
@ -220,7 +220,6 @@ VideoFrame* VideoFrame::Stretch(size_t dst_width, size_t dst_height,
|
|||||||
bool interpolate, bool vert_crop) const {
|
bool interpolate, bool vert_crop) const {
|
||||||
VideoFrame* dest = CreateEmptyFrame(static_cast<int>(dst_width),
|
VideoFrame* dest = CreateEmptyFrame(static_cast<int>(dst_width),
|
||||||
static_cast<int>(dst_height),
|
static_cast<int>(dst_height),
|
||||||
GetPixelWidth(), GetPixelHeight(),
|
|
||||||
GetTimeStamp());
|
GetTimeStamp());
|
||||||
if (dest) {
|
if (dest) {
|
||||||
StretchToFrame(dest, interpolate, vert_crop);
|
StretchToFrame(dest, interpolate, vert_crop);
|
||||||
|
|||||||
@ -41,8 +41,13 @@ class VideoFrame {
|
|||||||
VideoFrame() {}
|
VideoFrame() {}
|
||||||
virtual ~VideoFrame() {}
|
virtual ~VideoFrame() {}
|
||||||
|
|
||||||
|
virtual bool InitToBlack(int w, int h, int64_t time_stamp) = 0;
|
||||||
|
|
||||||
|
// TODO(nisse): Old signature. Delete after chrome is updated.
|
||||||
virtual bool InitToBlack(int w, int h, size_t pixel_width,
|
virtual bool InitToBlack(int w, int h, size_t pixel_width,
|
||||||
size_t pixel_height, int64_t time_stamp) = 0;
|
size_t pixel_height, int64_t time_stamp) {
|
||||||
|
return InitToBlack(w, h, time_stamp);
|
||||||
|
}
|
||||||
// Creates a frame from a raw sample with FourCC |format| and size |w| x |h|.
|
// Creates a frame from a raw sample with FourCC |format| and size |w| x |h|.
|
||||||
// |h| can be negative indicating a vertically flipped image.
|
// |h| can be negative indicating a vertically flipped image.
|
||||||
// |dw| is destination width; can be less than |w| if cropping is desired.
|
// |dw| is destination width; can be less than |w| if cropping is desired.
|
||||||
@ -56,8 +61,6 @@ class VideoFrame {
|
|||||||
int dh,
|
int dh,
|
||||||
uint8_t* sample,
|
uint8_t* sample,
|
||||||
size_t sample_size,
|
size_t sample_size,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp,
|
int64_t time_stamp,
|
||||||
webrtc::VideoRotation rotation,
|
webrtc::VideoRotation rotation,
|
||||||
bool apply_rotation) = 0;
|
bool apply_rotation) = 0;
|
||||||
@ -92,11 +95,6 @@ class VideoFrame {
|
|||||||
virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
|
virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
|
||||||
const = 0;
|
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 int64_t GetTimeStamp() const = 0;
|
||||||
virtual void SetTimeStamp(int64_t time_stamp) = 0;
|
virtual void SetTimeStamp(int64_t time_stamp) = 0;
|
||||||
|
|
||||||
@ -209,8 +207,7 @@ class VideoFrame {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Creates an empty frame.
|
// Creates an empty frame.
|
||||||
virtual VideoFrame *CreateEmptyFrame(int w, int h, size_t pixel_width,
|
virtual VideoFrame *CreateEmptyFrame(int w, int h,
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp) const = 0;
|
int64_t time_stamp) const = 0;
|
||||||
virtual void SetRotation(webrtc::VideoRotation rotation) = 0;
|
virtual void SetRotation(webrtc::VideoRotation rotation) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -152,7 +152,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (int i = 0; i < repeat_; ++i) {
|
for (int i = 0; i < repeat_; ++i) {
|
||||||
ret = frame->Init(format, width, height, dw, dh,
|
ret = frame->Init(format, width, height, dw, dh,
|
||||||
sample, sample_size, 1, 1, 0, rotation);
|
sample, sample_size, 0, rotation);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
|
|
||||||
const uint8_t* start = reinterpret_cast<const uint8_t*>(ms->GetBuffer());
|
const uint8_t* start = reinterpret_cast<const uint8_t*>(ms->GetBuffer());
|
||||||
int awidth = (width + 1) & ~1;
|
int awidth = (width + 1) & ~1;
|
||||||
frame->InitToBlack(width, height, 1, 1, 0);
|
frame->InitToBlack(width, height, 0);
|
||||||
int stride_y = frame->GetYPitch();
|
int stride_y = frame->GetYPitch();
|
||||||
int stride_u = frame->GetUPitch();
|
int stride_u = frame->GetUPitch();
|
||||||
int stride_v = frame->GetVPitch();
|
int stride_v = frame->GetVPitch();
|
||||||
@ -339,7 +339,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
start = start + pitch * (height - 1);
|
start = start + pitch * (height - 1);
|
||||||
pitch = -pitch;
|
pitch = -pitch;
|
||||||
}
|
}
|
||||||
frame->InitToBlack(width, height, 1, 1, 0);
|
frame->InitToBlack(width, height, 0);
|
||||||
int stride_y = frame->GetYPitch();
|
int stride_y = frame->GetYPitch();
|
||||||
int stride_u = frame->GetUPitch();
|
int stride_u = frame->GetUPitch();
|
||||||
int stride_v = frame->GetVPitch();
|
int stride_v = frame->GetVPitch();
|
||||||
@ -465,8 +465,6 @@ class VideoFrameTest : public testing::Test {
|
|||||||
static bool IsEqual(const cricket::VideoFrame& frame,
|
static bool IsEqual(const cricket::VideoFrame& frame,
|
||||||
size_t width,
|
size_t width,
|
||||||
size_t height,
|
size_t height,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp,
|
int64_t time_stamp,
|
||||||
const uint8_t* y,
|
const uint8_t* y,
|
||||||
uint32_t ypitch,
|
uint32_t ypitch,
|
||||||
@ -477,8 +475,6 @@ class VideoFrameTest : public testing::Test {
|
|||||||
int max_error) {
|
int max_error) {
|
||||||
return IsSize(frame, static_cast<uint32_t>(width),
|
return IsSize(frame, static_cast<uint32_t>(width),
|
||||||
static_cast<uint32_t>(height)) &&
|
static_cast<uint32_t>(height)) &&
|
||||||
frame.GetPixelWidth() == pixel_width &&
|
|
||||||
frame.GetPixelHeight() == pixel_height &&
|
|
||||||
frame.GetTimeStamp() == time_stamp &&
|
frame.GetTimeStamp() == time_stamp &&
|
||||||
IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch,
|
IsPlaneEqual("y", frame.GetYPlane(), frame.GetYPitch(), y, ypitch,
|
||||||
static_cast<uint32_t>(width),
|
static_cast<uint32_t>(width),
|
||||||
@ -496,7 +492,6 @@ class VideoFrameTest : public testing::Test {
|
|||||||
int max_error) {
|
int max_error) {
|
||||||
return IsEqual(frame1,
|
return IsEqual(frame1,
|
||||||
frame2.GetWidth(), frame2.GetHeight(),
|
frame2.GetWidth(), frame2.GetHeight(),
|
||||||
frame2.GetPixelWidth(), frame2.GetPixelHeight(),
|
|
||||||
frame2.GetTimeStamp(),
|
frame2.GetTimeStamp(),
|
||||||
frame2.GetYPlane(), frame2.GetYPitch(),
|
frame2.GetYPlane(), frame2.GetYPitch(),
|
||||||
frame2.GetUPlane(), frame2.GetUPitch(),
|
frame2.GetUPlane(), frame2.GetUPitch(),
|
||||||
@ -512,7 +507,6 @@ class VideoFrameTest : public testing::Test {
|
|||||||
IsEqual(frame1,
|
IsEqual(frame1,
|
||||||
frame2.GetWidth() - hcrop * 2,
|
frame2.GetWidth() - hcrop * 2,
|
||||||
frame2.GetHeight() - vcrop * 2,
|
frame2.GetHeight() - vcrop * 2,
|
||||||
frame2.GetPixelWidth(), frame2.GetPixelHeight(),
|
|
||||||
frame2.GetTimeStamp(),
|
frame2.GetTimeStamp(),
|
||||||
frame2.GetYPlane() + vcrop * frame2.GetYPitch()
|
frame2.GetYPlane() + vcrop * frame2.GetYPitch()
|
||||||
+ hcrop,
|
+ hcrop,
|
||||||
@ -549,7 +543,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
const uint8_t* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
||||||
const uint8_t* u = y + kWidth * kHeight;
|
const uint8_t* u = y + kWidth * kHeight;
|
||||||
const uint8_t* v = u + kWidth * kHeight / 4;
|
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));
|
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* y = reinterpret_cast<uint8_t*>(ms.get()->GetBuffer());
|
||||||
const uint8_t* v = y + kWidth * kHeight;
|
const uint8_t* v = y + kWidth * kHeight;
|
||||||
const uint8_t* u = v + kWidth * kHeight / 4;
|
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));
|
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, \
|
EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \
|
||||||
kHeight, \
|
kHeight, \
|
||||||
reinterpret_cast<uint8_t*>(ms->GetBuffer()), \
|
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 width_rotate = static_cast<int>(frame1.GetWidth()); \
|
||||||
int height_rotate = static_cast<int>(frame1.GetHeight()); \
|
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( \
|
libyuv::I420Mirror( \
|
||||||
frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \
|
frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \
|
||||||
frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \
|
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, \
|
EXPECT_TRUE(frame2.Init(cricket::FOURCC_##FOURCC, kWidth, kHeight, kWidth, \
|
||||||
kHeight, \
|
kHeight, \
|
||||||
reinterpret_cast<uint8_t*>(ms->GetBuffer()), \
|
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 width_rotate = static_cast<int>(frame1.GetWidth()); \
|
||||||
int height_rotate = static_cast<int>(frame1.GetHeight()); \
|
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( \
|
libyuv::I420Rotate( \
|
||||||
frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \
|
frame2.GetYPlane(), frame2.GetYPitch(), frame2.GetUPlane(), \
|
||||||
frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \
|
frame2.GetUPitch(), frame2.GetVPlane(), frame2.GetVPitch(), \
|
||||||
@ -968,12 +962,12 @@ class VideoFrameTest : public testing::Test {
|
|||||||
uint8_t pixel[3] = {1, 2, 3};
|
uint8_t pixel[3] = {1, 2, 3};
|
||||||
for (int i = 0; i < repeat_; ++i) {
|
for (int i = 0; i < repeat_; ++i) {
|
||||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
|
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* y = pixel;
|
||||||
const uint8_t* u = y + 1;
|
const uint8_t* u = y + 1;
|
||||||
const uint8_t* v = u + 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.
|
// 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);
|
memset(pixels5x5, 1, 5 * 5 + ((5 + 1) / 2 * (5 + 1) / 2) * 2);
|
||||||
for (int i = 0; i < repeat_; ++i) {
|
for (int i = 0; i < repeat_; ++i) {
|
||||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, pixels5x5,
|
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 5, 5, 5, 5, pixels5x5,
|
||||||
sizeof(pixels5x5), 1, 1, 0,
|
sizeof(pixels5x5), 0,
|
||||||
webrtc::kVideoRotation_0));
|
webrtc::kVideoRotation_0));
|
||||||
}
|
}
|
||||||
EXPECT_EQ(5u, frame.GetWidth());
|
EXPECT_EQ(5u, frame.GetWidth());
|
||||||
@ -999,7 +993,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
uint8_t pixel[4] = {64, 128, 192, 255};
|
uint8_t pixel[4] = {64, 128, 192, 255};
|
||||||
for (int i = 0; i < repeat_; ++i) {
|
for (int i = 0; i < repeat_; ++i) {
|
||||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, pixel,
|
EXPECT_TRUE(frame.Init(cricket::FOURCC_ARGB, 1, 1, 1, 1, pixel,
|
||||||
sizeof(pixel), 1, 1, 0,
|
sizeof(pixel), 0,
|
||||||
webrtc::kVideoRotation_0));
|
webrtc::kVideoRotation_0));
|
||||||
}
|
}
|
||||||
// Convert back to ARGB.
|
// Convert back to ARGB.
|
||||||
@ -1349,7 +1343,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
void ConstructBlack() {
|
void ConstructBlack() {
|
||||||
T frame;
|
T frame;
|
||||||
for (int i = 0; i < repeat_; ++i) {
|
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(IsSize(frame, kWidth, kHeight));
|
||||||
EXPECT_TRUE(IsBlack(frame));
|
EXPECT_TRUE(IsBlack(frame));
|
||||||
@ -1415,14 +1409,14 @@ class VideoFrameTest : public testing::Test {
|
|||||||
ASSERT_TRUE(ms.get() != NULL);
|
ASSERT_TRUE(ms.get() != NULL);
|
||||||
size_t data_size;
|
size_t data_size;
|
||||||
ms->GetSize(&data_size);
|
ms->GetSize(&data_size);
|
||||||
EXPECT_TRUE(frame1.InitToBlack(kWidth, kHeight, 1, 1, 0));
|
EXPECT_TRUE(frame1.InitToBlack(kWidth, kHeight, 0));
|
||||||
EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 1, 1, 0));
|
EXPECT_TRUE(frame2.InitToBlack(kWidth, kHeight, 0));
|
||||||
EXPECT_TRUE(IsBlack(frame1));
|
EXPECT_TRUE(IsBlack(frame1));
|
||||||
EXPECT_TRUE(IsEqual(frame1, frame2, 0));
|
EXPECT_TRUE(IsEqual(frame1, frame2, 0));
|
||||||
EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth,
|
EXPECT_TRUE(frame1.Reset(cricket::FOURCC_I420, kWidth, kHeight, kWidth,
|
||||||
kHeight,
|
kHeight,
|
||||||
reinterpret_cast<uint8_t*>(ms->GetBuffer()),
|
reinterpret_cast<uint8_t*>(ms->GetBuffer()),
|
||||||
data_size, 1, 1, 0, rotation, apply_rotation));
|
data_size, 0, rotation, apply_rotation));
|
||||||
if (apply_rotation)
|
if (apply_rotation)
|
||||||
EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation());
|
EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation());
|
||||||
else
|
else
|
||||||
@ -1494,7 +1488,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
out,
|
out,
|
||||||
out_size, stride));
|
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) {
|
for (int i = 0; i < repeat_from; ++i) {
|
||||||
EXPECT_EQ(0, RGBToI420(out, stride,
|
EXPECT_EQ(0, RGBToI420(out, stride,
|
||||||
frame2.GetYPlane(), frame2.GetYPitch(),
|
frame2.GetYPlane(), frame2.GetYPitch(),
|
||||||
@ -1915,7 +1909,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
uint8_t pixel[3] = {1, 2, 3};
|
uint8_t pixel[3] = {1, 2, 3};
|
||||||
T frame;
|
T frame;
|
||||||
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
|
EXPECT_TRUE(frame.Init(cricket::FOURCC_I420, 1, 1, 1, 1, pixel,
|
||||||
sizeof(pixel), 1, 1, 0,
|
sizeof(pixel), 0,
|
||||||
webrtc::kVideoRotation_0));
|
webrtc::kVideoRotation_0));
|
||||||
for (int i = 0; i < repeat_; ++i) {
|
for (int i = 0; i < repeat_; ++i) {
|
||||||
EXPECT_EQ(out_size, frame.CopyToBuffer(out.get(), out_size));
|
EXPECT_EQ(out_size, frame.CopyToBuffer(out.get(), out_size));
|
||||||
@ -1929,7 +1923,7 @@ class VideoFrameTest : public testing::Test {
|
|||||||
void StretchToFrame() {
|
void StretchToFrame() {
|
||||||
// Create the source frame as a black frame.
|
// Create the source frame as a black frame.
|
||||||
T source;
|
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));
|
EXPECT_TRUE(IsSize(source, kWidth * 2, kHeight * 2));
|
||||||
|
|
||||||
// Create the target frame by loading from a file.
|
// Create the target frame by loading from a file.
|
||||||
|
|||||||
@ -40,8 +40,6 @@ using webrtc::kVPlane;
|
|||||||
namespace cricket {
|
namespace cricket {
|
||||||
|
|
||||||
WebRtcVideoFrame::WebRtcVideoFrame():
|
WebRtcVideoFrame::WebRtcVideoFrame():
|
||||||
pixel_width_(0),
|
|
||||||
pixel_height_(0),
|
|
||||||
time_stamp_ns_(0),
|
time_stamp_ns_(0),
|
||||||
rotation_(webrtc::kVideoRotation_0) {}
|
rotation_(webrtc::kVideoRotation_0) {}
|
||||||
|
|
||||||
@ -50,8 +48,6 @@ WebRtcVideoFrame::WebRtcVideoFrame(
|
|||||||
int64_t time_stamp_ns,
|
int64_t time_stamp_ns,
|
||||||
webrtc::VideoRotation rotation)
|
webrtc::VideoRotation rotation)
|
||||||
: video_frame_buffer_(buffer),
|
: video_frame_buffer_(buffer),
|
||||||
pixel_width_(1),
|
|
||||||
pixel_height_(1),
|
|
||||||
time_stamp_ns_(time_stamp_ns),
|
time_stamp_ns_(time_stamp_ns),
|
||||||
rotation_(rotation) {
|
rotation_(rotation) {
|
||||||
}
|
}
|
||||||
@ -65,12 +61,10 @@ bool WebRtcVideoFrame::Init(uint32_t format,
|
|||||||
int dh,
|
int dh,
|
||||||
uint8_t* sample,
|
uint8_t* sample,
|
||||||
size_t sample_size,
|
size_t sample_size,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp_ns,
|
int64_t time_stamp_ns,
|
||||||
webrtc::VideoRotation rotation) {
|
webrtc::VideoRotation rotation) {
|
||||||
return Reset(format, w, h, dw, dh, sample, sample_size, pixel_width,
|
return Reset(format, w, h, dw, dh, sample, sample_size,
|
||||||
pixel_height, time_stamp_ns, rotation,
|
time_stamp_ns, rotation,
|
||||||
true /*apply_rotation*/);
|
true /*apply_rotation*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,13 +72,13 @@ bool WebRtcVideoFrame::Init(const CapturedFrame* frame, int dw, int dh,
|
|||||||
bool apply_rotation) {
|
bool apply_rotation) {
|
||||||
return Reset(frame->fourcc, frame->width, frame->height, dw, dh,
|
return Reset(frame->fourcc, frame->width, frame->height, dw, dh,
|
||||||
static_cast<uint8_t*>(frame->data), frame->data_size,
|
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);
|
frame->rotation, apply_rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebRtcVideoFrame::InitToBlack(int w, int h, size_t pixel_width,
|
bool WebRtcVideoFrame::InitToBlack(int w, int h,
|
||||||
size_t pixel_height, int64_t time_stamp_ns) {
|
int64_t time_stamp_ns) {
|
||||||
InitToEmptyBuffer(w, h, pixel_width, pixel_height, time_stamp_ns);
|
InitToEmptyBuffer(w, h, time_stamp_ns);
|
||||||
return SetToBlack();
|
return SetToBlack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,8 +145,6 @@ WebRtcVideoFrame::GetVideoFrameBuffer() const {
|
|||||||
VideoFrame* WebRtcVideoFrame::Copy() const {
|
VideoFrame* WebRtcVideoFrame::Copy() const {
|
||||||
WebRtcVideoFrame* new_frame = new WebRtcVideoFrame(
|
WebRtcVideoFrame* new_frame = new WebRtcVideoFrame(
|
||||||
video_frame_buffer_, time_stamp_ns_, rotation_);
|
video_frame_buffer_, time_stamp_ns_, rotation_);
|
||||||
new_frame->pixel_width_ = pixel_width_;
|
|
||||||
new_frame->pixel_height_ = pixel_height_;
|
|
||||||
return new_frame;
|
return new_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +188,6 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
|
|||||||
int dh,
|
int dh,
|
||||||
uint8_t* sample,
|
uint8_t* sample,
|
||||||
size_t sample_size,
|
size_t sample_size,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp_ns,
|
int64_t time_stamp_ns,
|
||||||
webrtc::VideoRotation rotation,
|
webrtc::VideoRotation rotation,
|
||||||
bool apply_rotation) {
|
bool apply_rotation) {
|
||||||
@ -217,7 +207,7 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
|
|||||||
new_height = dw;
|
new_height = dw;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitToEmptyBuffer(new_width, new_height, pixel_width, pixel_height,
|
InitToEmptyBuffer(new_width, new_height,
|
||||||
time_stamp_ns);
|
time_stamp_ns);
|
||||||
rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
|
rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
|
||||||
|
|
||||||
@ -247,19 +237,16 @@ bool WebRtcVideoFrame::Reset(uint32_t format,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VideoFrame* WebRtcVideoFrame::CreateEmptyFrame(
|
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 {
|
int64_t time_stamp_ns) const {
|
||||||
WebRtcVideoFrame* frame = new WebRtcVideoFrame();
|
WebRtcVideoFrame* frame = new WebRtcVideoFrame();
|
||||||
frame->InitToEmptyBuffer(w, h, pixel_width, pixel_height, time_stamp_ns);
|
frame->InitToEmptyBuffer(w, h, time_stamp_ns);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h, size_t pixel_width,
|
void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h,
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp_ns) {
|
int64_t time_stamp_ns) {
|
||||||
video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
|
video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
|
||||||
pixel_width_ = pixel_width;
|
|
||||||
pixel_height_ = pixel_height;
|
|
||||||
time_stamp_ns_ = time_stamp_ns;
|
time_stamp_ns_ = time_stamp_ns;
|
||||||
rotation_ = webrtc::kVideoRotation_0;
|
rotation_ = webrtc::kVideoRotation_0;
|
||||||
}
|
}
|
||||||
@ -292,7 +279,6 @@ const VideoFrame* WebRtcVideoFrame::GetCopyWithRotationApplied() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rotated_frame_.reset(CreateEmptyFrame(rotated_width, rotated_height,
|
rotated_frame_.reset(CreateEmptyFrame(rotated_width, rotated_height,
|
||||||
GetPixelWidth(), GetPixelHeight(),
|
|
||||||
GetTimeStamp()));
|
GetTimeStamp()));
|
||||||
|
|
||||||
// TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from
|
// TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from
|
||||||
|
|||||||
@ -59,18 +59,20 @@ class WebRtcVideoFrame : public VideoFrame {
|
|||||||
int dh,
|
int dh,
|
||||||
uint8_t* sample,
|
uint8_t* sample,
|
||||||
size_t sample_size,
|
size_t sample_size,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp_ns,
|
int64_t time_stamp_ns,
|
||||||
webrtc::VideoRotation rotation);
|
webrtc::VideoRotation rotation);
|
||||||
|
|
||||||
bool Init(const CapturedFrame* frame, int dw, int dh, bool apply_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,
|
void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
|
||||||
int64_t time_stamp_ns);
|
|
||||||
|
|
||||||
bool InitToBlack(int w, int h, size_t pixel_width, size_t pixel_height,
|
// TODO(nisse): Old signature. Delete after chrome is updated.
|
||||||
int64_t time_stamp_ns) override;
|
void InitToEmptyBuffer(int w, int h, size_t pixel_width, size_t pixel_height,
|
||||||
|
int64_t time_stamp_ns) {
|
||||||
|
InitToEmptyBuffer(w, h, time_stamp_ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitToBlack(int w, int h, int64_t time_stamp_ns) override;
|
||||||
|
|
||||||
// From base class VideoFrame.
|
// From base class VideoFrame.
|
||||||
bool Reset(uint32_t format,
|
bool Reset(uint32_t format,
|
||||||
@ -80,8 +82,6 @@ class WebRtcVideoFrame : public VideoFrame {
|
|||||||
int dh,
|
int dh,
|
||||||
uint8_t* sample,
|
uint8_t* sample,
|
||||||
size_t sample_size,
|
size_t sample_size,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp_ns,
|
int64_t time_stamp_ns,
|
||||||
webrtc::VideoRotation rotation,
|
webrtc::VideoRotation rotation,
|
||||||
bool apply_rotation) override;
|
bool apply_rotation) override;
|
||||||
@ -101,8 +101,6 @@ class WebRtcVideoFrame : public VideoFrame {
|
|||||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
|
||||||
const override;
|
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_; }
|
int64_t GetTimeStamp() const override { return time_stamp_ns_; }
|
||||||
void SetTimeStamp(int64_t time_stamp_ns) override {
|
void SetTimeStamp(int64_t time_stamp_ns) override {
|
||||||
time_stamp_ns_ = time_stamp_ns;
|
time_stamp_ns_ = time_stamp_ns;
|
||||||
@ -128,14 +126,11 @@ class WebRtcVideoFrame : public VideoFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VideoFrame* CreateEmptyFrame(int w, int h, size_t pixel_width,
|
VideoFrame* CreateEmptyFrame(int w, int h,
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp_ns) const override;
|
int64_t time_stamp_ns) const override;
|
||||||
|
|
||||||
// An opaque reference counted handle that stores the pixel data.
|
// An opaque reference counted handle that stores the pixel data.
|
||||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
|
||||||
size_t pixel_width_;
|
|
||||||
size_t pixel_height_;
|
|
||||||
int64_t time_stamp_ns_;
|
int64_t time_stamp_ns_;
|
||||||
webrtc::VideoRotation rotation_;
|
webrtc::VideoRotation rotation_;
|
||||||
|
|
||||||
|
|||||||
@ -39,11 +39,9 @@ class WebRtcVideoTestFrame : public cricket::WebRtcVideoFrame {
|
|||||||
|
|
||||||
virtual VideoFrame* CreateEmptyFrame(int w,
|
virtual VideoFrame* CreateEmptyFrame(int w,
|
||||||
int h,
|
int h,
|
||||||
size_t pixel_width,
|
|
||||||
size_t pixel_height,
|
|
||||||
int64_t time_stamp) const override {
|
int64_t time_stamp) const override {
|
||||||
WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame();
|
WebRtcVideoTestFrame* frame = new WebRtcVideoTestFrame();
|
||||||
frame->InitToBlack(w, h, pixel_width, pixel_height, time_stamp);
|
frame->InitToBlack(w, h, time_stamp);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -64,8 +62,6 @@ class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
|
|||||||
// Build the CapturedFrame.
|
// Build the CapturedFrame.
|
||||||
cricket::CapturedFrame captured_frame;
|
cricket::CapturedFrame captured_frame;
|
||||||
captured_frame.fourcc = cricket::FOURCC_I420;
|
captured_frame.fourcc = cricket::FOURCC_I420;
|
||||||
captured_frame.pixel_width = 1;
|
|
||||||
captured_frame.pixel_height = 1;
|
|
||||||
captured_frame.time_stamp = 5678;
|
captured_frame.time_stamp = 5678;
|
||||||
captured_frame.rotation = frame_rotation;
|
captured_frame.rotation = frame_rotation;
|
||||||
captured_frame.width = frame_width;
|
captured_frame.width = frame_width;
|
||||||
@ -85,8 +81,6 @@ class WebRtcVideoFrameTest : public VideoFrameTest<cricket::WebRtcVideoFrame> {
|
|||||||
apply_rotation));
|
apply_rotation));
|
||||||
|
|
||||||
// Verify the new frame.
|
// Verify the new frame.
|
||||||
EXPECT_EQ(1u, frame.GetPixelWidth());
|
|
||||||
EXPECT_EQ(1u, frame.GetPixelHeight());
|
|
||||||
EXPECT_EQ(5678, frame.GetTimeStamp());
|
EXPECT_EQ(5678, frame.GetTimeStamp());
|
||||||
if (apply_rotation)
|
if (apply_rotation)
|
||||||
EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation());
|
EXPECT_EQ(webrtc::kVideoRotation_0, frame.GetRotation());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user