Clear scalability mode from stats when implementation changes.

It was discovered that if libvpx reported a scalability mode in getStats
(e.g. L3T3_KEY) and we then changed encoder implementation to an
RTCVideoEncoder (such as MediaFoundationVideoEncodeAccelerator),
getStats continued to report the old scalability mode value.

This CL makes sure to clear the scalability mode on encoder
implementation change or if the `codec_info` is missing.

We should update MediaFoundation to report L1T1 as well, but in the
meantime we should clear any old scalability modes values when the
implementation changes (if the scalability mode is not known it is
better to report nothing than to report an old misleading value).

Bug: chromium:1426440
Change-Id: I1b5f324c4d29a00a6c73404cbee0faa2ae9cd843
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/312900
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40467}
This commit is contained in:
Henrik Boström 2023-07-24 16:01:09 +02:00 committed by WebRTC LUCI CQ
parent 00c0660469
commit 92665682fe

View File

@ -977,8 +977,8 @@ void SendStatisticsProxy::OnSendEncodedImage(
stats->frames_encoded++;
stats->total_encode_time_ms += encoded_image.timing_.encode_finish_ms -
encoded_image.timing_.encode_start_ms;
if (codec_info)
stats->scalability_mode = codec_info->scalability_mode;
stats->scalability_mode =
codec_info ? codec_info->scalability_mode : absl::nullopt;
// Report resolution of the top spatial layer.
bool is_top_spatial_layer =
codec_info == nullptr || codec_info->end_of_picture;
@ -1059,6 +1059,11 @@ void SendStatisticsProxy::OnEncoderImplementationChanged(
implementation.name};
stats_.encoder_implementation_name = implementation.name;
stats_.power_efficient_encoder = implementation.is_hardware_accelerated;
// Clear cached scalability mode values, they may no longer be accurate.
for (auto& pair : stats_.substreams) {
VideoSendStream::StreamStats& stream_stats = pair.second;
stream_stats.scalability_mode = absl::nullopt;
}
}
int SendStatisticsProxy::GetInputFrameRate() const {