Allow gap on packet buffer fix with GFD

The current solution does not work for GFD since GFD is only parsed from the first packet of the frame. As a result, to access the generic information, we have to check every packet when traversing the packet buffer to find the first packet of frame. This fix is necessary to ensure temporal scaling works correctly with GFD.

Bug: webrtc:42225186
Change-Id: Iadda4ec690deab62c32eb6101583e6a6d75cfeaf
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/344840
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42836}
This commit is contained in:
Fan Zhou 2024-08-22 14:55:19 -07:00 committed by WebRTC LUCI CQ
parent 6793f831ff
commit 8771cf470d
2 changed files with 20 additions and 0 deletions

View File

@ -279,6 +279,14 @@ std::vector<std::unique_ptr<PacketBuffer::Packet>> PacketBuffer::FindFrames(
int idr_height = -1;
bool full_frame_found = false;
while (true) {
// GFD is only attached to first packet of frame, so update check on
// every packet.
if (buffer_[start_index] != nullptr) {
is_generic = buffer_[start_index]->video_header.generic.has_value();
if (is_generic) {
is_h264_descriptor = false;
}
}
++tested_packets;
if (!is_h264_descriptor) {

View File

@ -827,6 +827,18 @@ TEST_F(PacketBufferH264FrameGap, DisallowFrameGapForH264NoGeneric) {
IsEmpty());
}
TEST_F(PacketBufferH264FrameGap,
AllowFrameGapForH264WithGenericOnFirstPacketOnly) {
bool generic = true;
InsertH264(1, kKeyFrame, kFirst, kLast, 1001, {}, 0, 0, generic);
InsertH264(3, kDeltaFrame, kFirst, kNotLast, 1003, {}, 0, 0, generic);
// Second packet is not generic, but we can still output frame with 2 packets.
EXPECT_THAT(
InsertH264(4, kDeltaFrame, kNotFirst, kLast, 1003, {}, 0, 0, !generic)
.packets,
SizeIs(2));
}
} // namespace
} // namespace video_coding
} // namespace webrtc