I420VideoFrame: Remove functions set_width and set_height

This is a partial reland of https://webrtc-codereview.appspot.com/39939004/.

The functions set_width and set_height in I420VideoFrame are not needed and just add complexity.

R=perkj@webrtc.org, tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/41009004

Cr-Commit-Position: refs/heads/master@{#8556}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8556 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/common_video/i420_video_frame.cc b/webrtc/common_video/i420_video_frame.cc
index 6924708..829d5a7 100644
--- a/webrtc/common_video/i420_video_frame.cc
+++ b/webrtc/common_video/i420_video_frame.cc
@@ -151,24 +151,6 @@
   return -1;
 }
 
-int I420VideoFrame::set_width(int width) {
-  if (CheckDimensions(width, height_,
-                      y_plane_.stride(), u_plane_.stride(),
-                      v_plane_.stride()) < 0)
-    return -1;
-  width_ = width;
-  return 0;
-}
-
-int I420VideoFrame::set_height(int height) {
-  if (CheckDimensions(width_, height,
-                      y_plane_.stride(), u_plane_.stride(),
-                      v_plane_.stride()) < 0)
-    return -1;
-  height_ = height;
-  return 0;
-}
-
 bool I420VideoFrame::IsZeroSize() const {
   return (y_plane_.IsZeroSize() && u_plane_.IsZeroSize() &&
     v_plane_.IsZeroSize());
diff --git a/webrtc/common_video/i420_video_frame_unittest.cc b/webrtc/common_video/i420_video_frame_unittest.cc
index 2b96634..1679df8 100644
--- a/webrtc/common_video/i420_video_frame_unittest.cc
+++ b/webrtc/common_video/i420_video_frame_unittest.cc
@@ -44,13 +44,8 @@
 TEST(TestI420VideoFrame, WidthHeightValues) {
   I420VideoFrame frame;
   const int valid_value = 10;
-  const int invalid_value = -1;
   EXPECT_EQ(0, frame.CreateEmptyFrame(10, 10, 10, 14, 90));
   EXPECT_EQ(valid_value, frame.width());
-  EXPECT_EQ(invalid_value, frame.set_width(invalid_value));
-  EXPECT_EQ(valid_value, frame.height());
-  EXPECT_EQ(valid_value, frame.height());
-  EXPECT_EQ(invalid_value, frame.set_height(0));
   EXPECT_EQ(valid_value, frame.height());
   frame.set_timestamp(123u);
   EXPECT_EQ(123u, frame.timestamp());
diff --git a/webrtc/common_video/texture_video_frame.cc b/webrtc/common_video/texture_video_frame.cc
index ce6a040..a03e096 100644
--- a/webrtc/common_video/texture_video_frame.cc
+++ b/webrtc/common_video/texture_video_frame.cc
@@ -20,8 +20,8 @@
                                      uint32_t timestamp,
                                      int64_t render_time_ms)
     : handle_(handle) {
-  set_width(width);
-  set_height(height);
+  width_ = width;
+  height_ = height;
   set_timestamp(timestamp);
   set_render_time_ms(render_time_ms);
 }
diff --git a/webrtc/common_video/texture_video_frame_unittest.cc b/webrtc/common_video/texture_video_frame_unittest.cc
index f574833..c8c21c4 100644
--- a/webrtc/common_video/texture_video_frame_unittest.cc
+++ b/webrtc/common_video/texture_video_frame_unittest.cc
@@ -40,10 +40,6 @@
   EXPECT_EQ(10, frame.render_time_ms());
   EXPECT_EQ(&handle, frame.native_handle());
 
-  EXPECT_EQ(0, frame.set_width(320));
-  EXPECT_EQ(320, frame.width());
-  EXPECT_EQ(0, frame.set_height(240));
-  EXPECT_EQ(240, frame.height());
   frame.set_timestamp(200);
   EXPECT_EQ(200u, frame.timestamp());
   frame.set_render_time_ms(20);
diff --git a/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.cc b/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.cc
index 70e19cc..5ca2feb 100644
--- a/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.cc
+++ b/webrtc/modules/video_processing/main/test/unit_test/video_processing_unittest.cc
@@ -91,8 +91,6 @@
   VideoProcessingModule::FrameStats stats;
   // Video frame with unallocated buffer.
   I420VideoFrame videoFrame;
-  videoFrame.set_width(width_);
-  videoFrame.set_height(height_);
 
   EXPECT_EQ(-3, vpm_->GetFrameStats(&stats, videoFrame));
 
@@ -120,22 +118,21 @@
 TEST_F(VideoProcessingModuleTest, HandleBadSize) {
   VideoProcessingModule::FrameStats stats;
 
-  video_frame_.ResetSize();
-  video_frame_.set_width(width_);
-  video_frame_.set_height(0);
-  EXPECT_EQ(-3, vpm_->GetFrameStats(&stats, video_frame_));
+  I420VideoFrame bad_frame;
+  bad_frame.CreateEmptyFrame(width_, 0, width_, (width_ + 1) / 2,
+                             (width_ + 1) / 2);
+  EXPECT_EQ(-3, vpm_->GetFrameStats(&stats, bad_frame));
 
-  EXPECT_EQ(-1, vpm_->ColorEnhancement(&video_frame_));
+  EXPECT_EQ(-1, vpm_->ColorEnhancement(&bad_frame));
 
-  EXPECT_EQ(-1, vpm_->Deflickering(&video_frame_, &stats));
+  EXPECT_EQ(-1, vpm_->Deflickering(&bad_frame, &stats));
 
-  EXPECT_EQ(-3, vpm_->BrightnessDetection(video_frame_, stats));
+  EXPECT_EQ(-3, vpm_->BrightnessDetection(bad_frame, stats));
 
   EXPECT_EQ(VPM_PARAMETER_ERROR, vpm_->SetTargetResolution(0,0,0));
 
   I420VideoFrame *out_frame = NULL;
-  EXPECT_EQ(VPM_PARAMETER_ERROR, vpm_->PreprocessFrame(video_frame_,
-                                                       &out_frame));
+  EXPECT_EQ(VPM_PARAMETER_ERROR, vpm_->PreprocessFrame(bad_frame, &out_frame));
 }
 
 TEST_F(VideoProcessingModuleTest, IdenticalResultsAfterReset) {
@@ -335,8 +332,9 @@
                int cropped_width,
                int cropped_height,
                I420VideoFrame* cropped_frame) {
-  cropped_frame->set_width(cropped_width);
-  cropped_frame->set_height(cropped_height);
+  cropped_frame->CreateEmptyFrame(cropped_width, cropped_height, cropped_width,
+                                  (cropped_width + 1) / 2,
+                                  (cropped_width + 1) / 2);
   EXPECT_EQ(0,
             ConvertToI420(kI420, source_data, offset_x, offset_y, source_width,
                           source_height, 0, kRotateNone, cropped_frame));
diff --git a/webrtc/video_frame.h b/webrtc/video_frame.h
index 2dd7c61..451dd32 100644
--- a/webrtc/video_frame.h
+++ b/webrtc/video_frame.h
@@ -111,12 +111,6 @@
   // Get allocated stride per plane.
   virtual int stride(PlaneType type) const;
 
-  // Set frame width.
-  virtual int set_width(int width);
-
-  // Set frame height.
-  virtual int set_height(int height);
-
   // Get frame width.
   virtual int width() const { return width_; }
 
@@ -180,6 +174,9 @@
                               int stride_y,
                               int stride_u,
                               int stride_v);
+  // TODO(magjed): Move these to an internal frame buffer instead.
+  int width_;
+  int height_;
 
  private:
   // Get the pointer to a specific plane.
@@ -190,8 +187,6 @@
   Plane y_plane_;
   Plane u_plane_;
   Plane v_plane_;
-  int width_;
-  int height_;
   uint32_t timestamp_;
   int64_t ntp_time_ms_;
   int64_t render_time_ms_;