Mark frames with inter_layer_predicted=true as delta frames

As it is currently implemented, the VP9 depacketizer decides packet's frame type based on p_bit ("Inter-picture predicted layer frame"). p_bit is set to 0 for upper spatial layer frames of keyframe since they do not have temporal refs. This results in marking packets of upper spatial layer frames, and, eventually these frames, of SVC keyframes as "keyframe" while they are in fact delta frames.

Normally spatial layer frames are merged into a superframe and the superframe is passed to decoder. But passing individual layers to a single decoder instance is a valid scenario too and is used in downstream projects. In this case, an upper layer frame marked as keyframe may cause decoder reset [2] and break decoding.

This CL changes frame type decision logic in the VP9 depacketizer such that only packets with both P and D (inter-layer predicted) bits unset are considered as keyframe packets.

When spatial layer frames are merged into a superframe in CombineAndDeleteFrames [1], frame type of the superframe is inferred from the lowest spatial layer frame.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/modules/video_coding/frame_helpers.cc;l=53

[2] https://source.corp.google.com/piper///depot/google3/third_party/webrtc/files/stable/webrtc/modules/video_coding/codecs/vp9/libvpx_vp9_decoder.cc;l=209

Bug: webrtc:15827
Change-Id: Idc3445636f0eae0192dac998876fedec48628560
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/343342
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41939}
This commit is contained in:
Sergey Silkin 2024-03-21 10:26:12 +01:00 committed by WebRTC LUCI CQ
parent 3277fe1d75
commit 7ae48c452a

View file

@ -180,9 +180,6 @@ int VideoRtpDepacketizerVp9::ParseRtpPayload(
video_header->simulcastIdx = 0;
video_header->codec = kVideoCodecVP9;
video_header->frame_type =
p_bit ? VideoFrameType::kVideoFrameDelta : VideoFrameType::kVideoFrameKey;
auto& vp9_header =
video_header->video_type_header.emplace<RTPVideoHeaderVP9>();
vp9_header.InitRTPVideoHeaderVP9();
@ -211,6 +208,9 @@ int VideoRtpDepacketizerVp9::ParseRtpPayload(
video_header->height = vp9_header.height[0];
}
}
video_header->frame_type = p_bit || vp9_header.inter_layer_predicted
? VideoFrameType::kVideoFrameDelta
: VideoFrameType::kVideoFrameKey;
video_header->is_first_packet_in_frame = b_bit;
video_header->is_last_packet_in_frame = e_bit;