Move InitToBlack and Reset methods from cricket::VideoFrame to its subclass cricket::WebRtcVideoFrame.

BUG=webrtc:5682
R=perkj@webrtc.org

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

Cr-Commit-Position: refs/heads/master@{#12260}
This commit is contained in:
Niels Möller 2016-04-06 13:07:06 +02:00
parent 0bf612b3ec
commit 03bd4008b6
4 changed files with 16 additions and 76 deletions

View File

@ -24,25 +24,6 @@ class VideoFrame {
VideoFrame() {}
virtual ~VideoFrame() {}
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.
// |dh| is destination height, like |dw|, but must be a positive number.
// Returns whether the function succeeded or failed.
virtual bool Reset(uint32_t fourcc,
int w,
int h,
int dw,
int dh,
uint8_t* sample,
size_t sample_size,
int64_t time_stamp,
webrtc::VideoRotation rotation,
bool apply_rotation) = 0;
// Basic accessors.
// Note this is the width and height without rotation applied.
virtual int width() const = 0;

View File

@ -1371,48 +1371,6 @@ class VideoFrameTest : public testing::Test {
}
}
// Tests re-initing an existing image.
void Reset(webrtc::VideoRotation rotation, bool apply_rotation) {
T frame1, frame2;
std::unique_ptr<rtc::MemoryStream> ms(
LoadSample(kImageFilename));
ASSERT_TRUE(ms.get() != NULL);
size_t data_size;
ms->GetSize(&data_size);
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, 0, rotation, apply_rotation));
if (apply_rotation)
EXPECT_EQ(webrtc::kVideoRotation_0, frame1.GetVideoRotation());
else
EXPECT_EQ(rotation, frame1.GetVideoRotation());
// Swapp width and height if the frame is rotated 90 or 270 degrees.
if (apply_rotation && (rotation == webrtc::kVideoRotation_90
|| rotation == webrtc::kVideoRotation_270)) {
EXPECT_TRUE(kHeight == frame1.width());
EXPECT_TRUE(kWidth == frame1.height());
} else {
EXPECT_TRUE(kWidth == frame1.width());
EXPECT_TRUE(kHeight == frame1.height());
}
EXPECT_FALSE(IsBlack(frame1));
EXPECT_FALSE(IsEqual(frame1, frame2, 0));
}
void ResetAndApplyRotation() {
Reset(webrtc::kVideoRotation_90, true);
}
void ResetAndDontApplyRotation() {
Reset(webrtc::kVideoRotation_90, false);
}
//////////////////////
// Conversion tests //
//////////////////////

View File

@ -51,19 +51,7 @@ class WebRtcVideoFrame : public VideoFrame {
void InitToEmptyBuffer(int w, int h, int64_t time_stamp_ns);
bool InitToBlack(int w, int h, int64_t time_stamp_ns) override;
// From base class VideoFrame.
bool Reset(uint32_t format,
int w,
int h,
int dw,
int dh,
uint8_t* sample,
size_t sample_size,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation,
bool apply_rotation) override;
bool InitToBlack(int w, int h, int64_t time_stamp_ns);
int width() const override;
int height() const override;
@ -103,6 +91,21 @@ class WebRtcVideoFrame : public VideoFrame {
void SetRotation(webrtc::VideoRotation rotation) override {
rotation_ = rotation;
}
// 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.
// |dh| is destination height, like |dw|, but must be a positive number.
// Returns whether the function succeeded or failed.
bool Reset(uint32_t format,
int w,
int h,
int dw,
int dh,
uint8_t* sample,
size_t sample_size,
int64_t time_stamp_ns,
webrtc::VideoRotation rotation,
bool apply_rotation);
private:
VideoFrame* CreateEmptyFrame(int w, int h,

View File

@ -166,8 +166,6 @@ TEST_WEBRTCVIDEOFRAME(ValidateI420HugeSize)
// Re-evaluate once WebRTC switches to libyuv
// TEST_WEBRTCVIDEOFRAME(ConstructYuy2AllSizes)
// TEST_WEBRTCVIDEOFRAME(ConstructARGBAllSizes)
TEST_WEBRTCVIDEOFRAME(ResetAndApplyRotation)
TEST_WEBRTCVIDEOFRAME(ResetAndDontApplyRotation)
TEST_WEBRTCVIDEOFRAME(ConvertToABGRBuffer)
TEST_WEBRTCVIDEOFRAME(ConvertToABGRBufferStride)
TEST_WEBRTCVIDEOFRAME(ConvertToABGRBufferInverted)