Reland of Delete VideoFrame default constructor, and IsZeroSize method. (patchset #1 id:1 of https://codereview.webrtc.org/2574123002/ )
Reason for revert:
Fixing perf tests.
Original issue's description:
> Revert of Delete VideoFrame default constructor, and IsZeroSize method. (patchset #5 id:80001 of https://codereview.webrtc.org/2541863002/ )
>
> Reason for revert:
> Crashes perf tests, e.g.,
>
> ./out/Debug/webrtc_perf_tests --gtest_filter='FullStackTest.ScreenshareSlidesVP8_2TL_VeryLossyNet'
>
> dies with an assert related to rtc::Optional.
>
> Original issue's description:
> > Delete VideoFrame default constructor, and IsZeroSize method.
> >
> > This ensures that the video_frame_buffer method never can return a
> > null pointer.
> >
> > BUG=webrtc:6591
> >
> > Committed: https://crrev.com/bfcf561923a42005e4c7d66d8e72e5932155f997
> > Cr-Commit-Position: refs/heads/master@{#15574}
>
> TBR=magjed@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6591
>
> Committed: https://crrev.com/0989fbcad2ca4eb5805a77e8ebfefd3af06ade23
> Cr-Commit-Position: refs/heads/master@{#15597}
TBR=magjed@webrtc.org,stefan@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6591
Review-Url: https://codereview.webrtc.org/2574183002
Cr-Commit-Position: refs/heads/master@{#15633}
diff --git a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
index 6150aa8..e6f9995 100644
--- a/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
+++ b/webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc
@@ -308,10 +308,6 @@
ReportError();
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
- if (input_frame.IsZeroSize()) {
- ReportError();
- return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
- }
if (!encoded_image_callback_) {
LOG(LS_WARNING) << "InitEncode() has been called, but a callback function "
<< "has not been set with RegisterEncodeCompleteCallback()";
diff --git a/webrtc/modules/video_coding/codecs/i420/include/i420.h b/webrtc/modules/video_coding/codecs/i420/include/i420.h
index 0a8051f..1047ae0 100644
--- a/webrtc/modules/video_coding/codecs/i420/include/i420.h
+++ b/webrtc/modules/video_coding/codecs/i420/include/i420.h
@@ -131,7 +131,6 @@
uint16_t* width,
uint16_t* height);
- VideoFrame _decodedImage;
int _width;
int _height;
bool _inited;
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.h b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
index 3142946..f87ccc5 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
@@ -204,7 +204,6 @@
// Keep track of the last successful frame, since we need to write that
// when decoding fails:
uint8_t* last_successful_frame_buffer_;
- webrtc::VideoFrame source_frame_;
// To keep track of if we have excluded the first key frame from packet loss:
bool first_key_frame_has_been_excluded_;
// To tell the decoder previous frame have been dropped due to packet loss:
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
index 6e3ae4c..cb35fdc 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
@@ -300,7 +300,6 @@
// TODO(perkj): ensure that works going forward, and figure out how this
// affects webrtc:5683.
if ((dst_width == src_width && dst_height == src_height) ||
- input_image.IsZeroSize() ||
input_image.video_frame_buffer()->native_handle()) {
int ret = streaminfos_[stream_idx].encoder->Encode(
input_image, codec_specific_info, &stream_frame_types);
diff --git a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
index d4c4de6..5bcbb9b 100644
--- a/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc
@@ -13,6 +13,7 @@
#include <memory>
#include "webrtc/base/checks.h"
+#include "webrtc/base/optional.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
@@ -88,7 +89,7 @@
class Vp8UnitTestDecodeCompleteCallback : public webrtc::DecodedImageCallback {
public:
- explicit Vp8UnitTestDecodeCompleteCallback(VideoFrame* frame)
+ explicit Vp8UnitTestDecodeCompleteCallback(rtc::Optional<VideoFrame>* frame)
: decoded_frame_(frame), decode_complete(false) {}
int32_t Decoded(VideoFrame& frame) override;
int32_t Decoded(VideoFrame& frame, int64_t decode_time_ms) override {
@@ -98,7 +99,7 @@
bool DecodeComplete();
private:
- VideoFrame* decoded_frame_;
+ rtc::Optional<VideoFrame>* decoded_frame_;
bool decode_complete;
};
@@ -111,7 +112,7 @@
}
int Vp8UnitTestDecodeCompleteCallback::Decoded(VideoFrame& image) {
- *decoded_frame_ = image;
+ *decoded_frame_ = rtc::Optional<VideoFrame>(image);
decode_complete = true;
return 0;
}
@@ -184,8 +185,8 @@
int64_t startTime = rtc::TimeMillis();
while (rtc::TimeMillis() - startTime < kMaxWaitDecTimeMs) {
if (decode_complete_callback_->DecodeComplete()) {
- return CalcBufferSize(kI420, decoded_frame_.width(),
- decoded_frame_.height());
+ return CalcBufferSize(kI420, decoded_frame_->width(),
+ decoded_frame_->height());
}
}
return 0;
@@ -202,7 +203,7 @@
std::unique_ptr<VideoEncoder> encoder_;
std::unique_ptr<VideoDecoder> decoder_;
EncodedImage encoded_frame_;
- VideoFrame decoded_frame_;
+ rtc::Optional<VideoFrame> decoded_frame_;
VideoCodec codec_inst_;
TemporalLayersFactory tl_factory_;
};
@@ -252,10 +253,11 @@
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame_, false, NULL));
EXPECT_GT(WaitForDecodedFrame(), 0u);
+ ASSERT_TRUE(decoded_frame_);
// Compute PSNR on all planes (faster than SSIM).
- EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36);
- EXPECT_EQ(kTestTimestamp, decoded_frame_.timestamp());
- EXPECT_EQ(kTestNtpTimeMs, decoded_frame_.ntp_time_ms());
+ EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36);
+ EXPECT_EQ(kTestTimestamp, decoded_frame_->timestamp());
+ EXPECT_EQ(kTestNtpTimeMs, decoded_frame_->ntp_time_ms());
}
#if defined(WEBRTC_ANDROID)
@@ -280,7 +282,8 @@
encoded_frame_._frameType = kVideoFrameKey;
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->Decode(encoded_frame_, false, NULL));
- EXPECT_GT(I420PSNR(input_frame_.get(), &decoded_frame_), 36);
+ ASSERT_TRUE(decoded_frame_);
+ EXPECT_GT(I420PSNR(input_frame_.get(), &*decoded_frame_), 36);
}
} // namespace webrtc
diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
index df0e409..2fbceb1 100644
--- a/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/vp8_impl.cc
@@ -660,8 +660,6 @@
if (!inited_)
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
- if (frame.IsZeroSize())
- return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
if (encoded_complete_callback_ == NULL)
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
index bfb5606..4559d4a 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -486,9 +486,6 @@
if (!inited_) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
- if (input_image.IsZeroSize()) {
- return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
- }
if (encoded_complete_callback_ == NULL) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
diff --git a/webrtc/modules/video_coding/generic_encoder.cc b/webrtc/modules/video_coding/generic_encoder.cc
index 75bdc7c..1786e72 100644
--- a/webrtc/modules/video_coding/generic_encoder.cc
+++ b/webrtc/modules/video_coding/generic_encoder.cc
@@ -123,8 +123,14 @@
int32_t VCMGenericEncoder::RequestFrame(
const std::vector<FrameType>& frame_types) {
RTC_DCHECK_RUNS_SERIALIZED(&race_checker_);
- VideoFrame image;
- return encoder_->Encode(image, NULL, &frame_types);
+
+ // TODO(nisse): Used only with internal source. Delete as soon as
+ // that feature is removed. The only implementation I've been able
+ // to find ignores what's in the frame.
+ return encoder_->Encode(VideoFrame(I420Buffer::Create(1, 1),
+ kVideoRotation_0, 0),
+ NULL, &frame_types);
+ return 0;
}
bool VCMGenericEncoder::InternalSource() const {