From 03bd4008b61b7ead41528610de75adafa22d3faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 6 Apr 2016 13:07:06 +0200 Subject: [PATCH] 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} --- webrtc/media/base/videoframe.h | 19 --------- webrtc/media/base/videoframe_unittest.h | 42 ------------------- webrtc/media/engine/webrtcvideoframe.h | 29 +++++++------ .../media/engine/webrtcvideoframe_unittest.cc | 2 - 4 files changed, 16 insertions(+), 76 deletions(-) diff --git a/webrtc/media/base/videoframe.h b/webrtc/media/base/videoframe.h index df5352b149..6045bc08b4 100644 --- a/webrtc/media/base/videoframe.h +++ b/webrtc/media/base/videoframe.h @@ -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; diff --git a/webrtc/media/base/videoframe_unittest.h b/webrtc/media/base/videoframe_unittest.h index b01f0b856c..9e9b7dddb1 100644 --- a/webrtc/media/base/videoframe_unittest.h +++ b/webrtc/media/base/videoframe_unittest.h @@ -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 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(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 // ////////////////////// diff --git a/webrtc/media/engine/webrtcvideoframe.h b/webrtc/media/engine/webrtcvideoframe.h index 3af5fae48c..cb280b5e15 100644 --- a/webrtc/media/engine/webrtcvideoframe.h +++ b/webrtc/media/engine/webrtcvideoframe.h @@ -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, diff --git a/webrtc/media/engine/webrtcvideoframe_unittest.cc b/webrtc/media/engine/webrtcvideoframe_unittest.cc index 96db859e84..4b0e988d28 100644 --- a/webrtc/media/engine/webrtcvideoframe_unittest.cc +++ b/webrtc/media/engine/webrtcvideoframe_unittest.cc @@ -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)