Remove kSkipFrame usage.
Since padding is no longer sent on Encoded() callbacks, dummy callbacks
aren't required to generate padding. This skip-frame behavior can then
be removed to get rid of dummy callbacks though nothing was encoded. As
frames don't have to be generated for frames that don't have to be sent
we skip encoding frames that aren't intended to be sent either, reducing
CPU load.
BUG=
R=mflodman@webrtc.org, stefan@webrtc.org
Review URL: https://codereview.webrtc.org/1369923005 .
Cr-Original-Commit-Position: refs/heads/master@{#10181}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 5d0379da2cbdcce6f8494209c7ab559cd6de076e
diff --git a/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc b/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
index 7c4164c..1b59be3 100644
--- a/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
+++ b/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc
@@ -262,6 +262,10 @@
int src_width = input_image.width();
int src_height = input_image.height();
for (size_t stream_idx = 0; stream_idx < streaminfos_.size(); ++stream_idx) {
+ // Don't encode frames in resolutions that we don't intend to send.
+ if (!streaminfos_[stream_idx].send_stream)
+ continue;
+
std::vector<VideoFrameType> stream_frame_types;
if (send_key_frame) {
stream_frame_types.push_back(kKeyFrame);
@@ -390,23 +394,8 @@
CodecSpecificInfoVP8* vp8Info = &(stream_codec_specific.codecSpecific.VP8);
vp8Info->simulcastIdx = stream_idx;
- if (streaminfos_[stream_idx].send_stream) {
- return encoded_complete_callback_->Encoded(encodedImage,
- &stream_codec_specific,
- fragmentation);
- } else {
- EncodedImage dummy_image;
- // Required in case padding is applied to dropped frames.
- dummy_image._timeStamp = encodedImage._timeStamp;
- dummy_image.capture_time_ms_ = encodedImage.capture_time_ms_;
- dummy_image._encodedWidth = encodedImage._encodedWidth;
- dummy_image._encodedHeight = encodedImage._encodedHeight;
- dummy_image._length = 0;
- dummy_image._frameType = kSkipFrame;
- vp8Info->keyIdx = kNoKeyIdx;
- return encoded_complete_callback_->Encoded(dummy_image,
- &stream_codec_specific, NULL);
- }
+ return encoded_complete_callback_->Encoded(
+ encodedImage, &stream_codec_specific, fragmentation);
}
uint32_t SimulcastEncoderAdapter::GetStreamBitrate(
diff --git a/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc b/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
index fdca878..7dc75ed 100644
--- a/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
+++ b/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
@@ -351,6 +351,9 @@
TEST_F(TestSimulcastEncoderAdapterFake, EncodedCallbackForDifferentEncoders) {
SetupCodec();
+ // Set bitrates so that we send all layers.
+ adapter_->SetRates(1200, 30);
+
// At this point, the simulcast encoder adapter should have 3 streams: HD,
// quarter HD, and quarter quarter HD. We're going to mostly ignore the exact
// resolutions, to test that the adapter forwards on the correct resolution
diff --git a/modules/video_coding/codecs/vp8/simulcast_unittest.h b/modules/video_coding/codecs/vp8/simulcast_unittest.h
index 8e365a9..f1a069d 100644
--- a/modules/video_coding/codecs/vp8/simulcast_unittest.h
+++ b/modules/video_coding/codecs/vp8/simulcast_unittest.h
@@ -367,13 +367,6 @@
.Times(1)
.WillRepeatedly(Return(0));
}
- if (expected_video_streams < kNumberOfSimulcastStreams) {
- EXPECT_CALL(encoder_callback_, Encoded(
- AllOf(Field(&EncodedImage::_frameType, kSkipFrame),
- Field(&EncodedImage::_length, 0)), _, _))
- .Times(kNumberOfSimulcastStreams - expected_video_streams)
- .WillRepeatedly(Return(0));
- }
}
void VerifyTemporalIdxAndSyncForAllSpatialLayers(
diff --git a/modules/video_coding/codecs/vp8/vp8_impl.cc b/modules/video_coding/codecs/vp8/vp8_impl.cc
index 5714a07..e7a5b32 100644
--- a/modules/video_coding/codecs/vp8/vp8_impl.cc
+++ b/modules/video_coding/codecs/vp8/vp8_impl.cc
@@ -1018,17 +1018,6 @@
} else if (codec_.mode == kScreensharing) {
result = WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT;
}
- } else {
- // Required in case padding is applied to dropped frames.
- encoded_images_[encoder_idx]._length = 0;
- encoded_images_[encoder_idx]._frameType = kSkipFrame;
- codec_specific.codecType = kVideoCodecVP8;
- CodecSpecificInfoVP8* vp8Info = &(codec_specific.codecSpecific.VP8);
- vp8Info->pictureId = picture_id_[stream_idx];
- vp8Info->simulcastIdx = stream_idx;
- vp8Info->keyIdx = kNoKeyIdx;
- encoded_complete_callback_->Encoded(encoded_images_[encoder_idx],
- &codec_specific, NULL);
}
}
if (encoders_.size() == 1 && send_stream_[0]) {
diff --git a/modules/video_coding/main/source/encoded_frame.cc b/modules/video_coding/main/source/encoded_frame.cc
index 0fa4425..646dae3 100644
--- a/modules/video_coding/main/source/encoded_frame.cc
+++ b/modules/video_coding/main/source/encoded_frame.cc
@@ -233,11 +233,9 @@
return kVideoFrameKey;
case kDeltaFrame:
return kVideoFrameDelta;
- case kSkipFrame:
- return kFrameEmpty;
- default:
- return kVideoFrameDelta;
}
+ // Bogus default return value.
+ return kVideoFrameDelta;
}
VideoFrameType VCMEncodedFrame::ConvertFrameType(webrtc::FrameType frame_type) {
diff --git a/test/fake_encoder.cc b/test/fake_encoder.cc
index a840ddb..f85fb9a 100644
--- a/test/fake_encoder.cc
+++ b/test/fake_encoder.cc
@@ -100,10 +100,8 @@
encoded._encodedWidth = config_.simulcastStream[i].width;
encoded._encodedHeight = config_.simulcastStream[i].height;
// Always encode something on the first frame.
- if (min_stream_bits > bits_available && i > 0) {
- encoded._length = 0;
- encoded._frameType = kSkipFrame;
- }
+ if (min_stream_bits > bits_available && i > 0)
+ continue;
assert(callback_ != NULL);
if (callback_->Encoded(encoded, &specifics, NULL) != 0)
return -1;
diff --git a/video/send_statistics_proxy.cc b/video/send_statistics_proxy.cc
index 7316ee8..2aea976 100644
--- a/video/send_statistics_proxy.cc
+++ b/video/send_statistics_proxy.cc
@@ -168,8 +168,7 @@
stats->height = encoded_image._encodedHeight;
update_times_[ssrc].resolution_update_ms = clock_->TimeInMilliseconds();
- if (encoded_image._frameType != kSkipFrame)
- key_frame_counter_.Add(encoded_image._frameType == kKeyFrame);
+ key_frame_counter_.Add(encoded_image._frameType == kKeyFrame);
// TODO(asapersson): This is incorrect if simulcast layers are encoded on
// different threads and there is no guarantee that one frame of all layers
diff --git a/video_frame.h b/video_frame.h
index b71e0aa..626c013 100644
--- a/video_frame.h
+++ b/video_frame.h
@@ -169,9 +169,6 @@
enum VideoFrameType {
kKeyFrame = 0,
kDeltaFrame = 1,
- kGoldenFrame = 2,
- kAltRefFrame = 3,
- kSkipFrame = 4
};
// TODO(pbos): Rename EncodedFrame and reformat this class' members.