In GenericFrameInfo do not set frame_id and frame_diff

No code reads these properties.
They are recalculated by RtpPayloadParams
and set directly into RTPVideoHeader::generic.

Bug: webrtc:10342
Change-Id: Ib7bda4e6e5b0d0b3a585a848e3312fb66f8ae36d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/175127
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31269}
This commit is contained in:
Danil Chapovalov 2020-05-14 18:37:04 +02:00 committed by Commit Bot
parent 9b7232a68c
commit 8133ffb187
3 changed files with 1 additions and 57 deletions

View File

@ -40,7 +40,6 @@ struct GenericFrameInfo : public FrameDependencyTemplate {
GenericFrameInfo(const GenericFrameInfo&);
~GenericFrameInfo();
int64_t frame_id = 0;
absl::InlinedVector<CodecBufferUsage, kMaxEncoderBuffers> encoder_buffers;
};

View File

@ -251,7 +251,6 @@ VideoStreamEncoder::VideoStreamEncoder(
next_frame_types_(1, VideoFrameType::kVideoFrameDelta),
frame_encode_metadata_writer_(this),
experiment_groups_(GetExperimentGroups()),
next_frame_id_(0),
encoder_switch_experiment_(ParseEncoderSwitchFieldTrial()),
automatic_animation_detection_experiment_(
ParseAutomatincAnimationDetectionFieldTrial()),
@ -295,9 +294,6 @@ VideoStreamEncoder::VideoStreamEncoder(
initialize_processor_event.Set();
});
initialize_processor_event.Wait(rtc::Event::kForever);
for (auto& state : encoder_buffer_state_)
state.fill(std::numeric_limits<int64_t>::max());
}
VideoStreamEncoder::~VideoStreamEncoder() {
@ -1499,48 +1495,8 @@ EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage(
simulcast_id = encoded_image.SpatialIndex().value_or(0);
}
std::unique_ptr<CodecSpecificInfo> codec_info_copy;
{
rtc::CritScope cs(&encoded_image_lock_);
if (codec_specific_info && codec_specific_info->generic_frame_info) {
codec_info_copy =
std::make_unique<CodecSpecificInfo>(*codec_specific_info);
GenericFrameInfo& generic_info = *codec_info_copy->generic_frame_info;
generic_info.frame_id = next_frame_id_++;
if (encoder_buffer_state_.size() <= static_cast<size_t>(simulcast_id)) {
RTC_LOG(LS_ERROR) << "At most " << encoder_buffer_state_.size()
<< " simulcast streams supported.";
} else {
std::array<int64_t, kMaxEncoderBuffers>& state =
encoder_buffer_state_[simulcast_id];
for (const CodecBufferUsage& buffer : generic_info.encoder_buffers) {
if (state.size() <= static_cast<size_t>(buffer.id)) {
RTC_LOG(LS_ERROR)
<< "At most " << state.size() << " encoder buffers supported.";
break;
}
if (buffer.referenced) {
int64_t diff = generic_info.frame_id - state[buffer.id];
if (diff <= 0) {
RTC_LOG(LS_ERROR) << "Invalid frame diff: " << diff << ".";
} else if (absl::c_find(generic_info.frame_diffs, diff) ==
generic_info.frame_diffs.end()) {
generic_info.frame_diffs.push_back(diff);
}
}
if (buffer.updated)
state[buffer.id] = generic_info.frame_id;
}
}
}
}
EncodedImageCallback::Result result = sink_->OnEncodedImage(
image_copy, codec_info_copy ? codec_info_copy.get() : codec_specific_info,
image_copy, codec_specific_info,
fragmentation_copy ? fragmentation_copy.get() : fragmentation);
// We are only interested in propagating the meta-data about the image, not

View File

@ -341,17 +341,6 @@ class VideoStreamEncoder : public VideoStreamEncoderInterface,
// experiment group numbers incremented by 1.
const std::array<uint8_t, 2> experiment_groups_;
// TODO(philipel): Remove this lock and run on |encoder_queue_| instead.
rtc::CriticalSection encoded_image_lock_;
int64_t next_frame_id_ RTC_GUARDED_BY(encoded_image_lock_);
// This array is used as a map from simulcast id to an encoder's buffer
// state. For every buffer of the encoder we keep track of the last frame id
// that updated that buffer.
std::array<std::array<int64_t, kMaxEncoderBuffers>, kMaxSimulcastStreams>
encoder_buffer_state_ RTC_GUARDED_BY(encoded_image_lock_);
struct EncoderSwitchExperiment {
struct Thresholds {
absl::optional<DataRate> bitrate;