Add some comments for H265 RTP depacketizer.

This CL helps readers to understand which part of the spec
VideoRtpDepacketizerH265 implements.

Bug: webrtc:13485
Change-Id: Ie78a6ce781e6af559d59b1b07ce2854115368a86
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/340008
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41768}
This commit is contained in:
Jianjun Zhu 2024-02-20 10:05:34 +08:00 committed by WebRTC LUCI CQ
parent 36d5eec6e1
commit 41c44cde41

View File

@ -29,6 +29,8 @@
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
// RTP Payload Format for HEVC: https://datatracker.ietf.org/doc/html/rfc7798
namespace webrtc {
namespace {
@ -55,6 +57,10 @@ bool ParseApStartOffsets(const uint8_t* nalu_ptr,
return true;
}
// Single NALU packet structure
// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.1
// Aggregation Packet (AP) strcture
// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessApOrSingleNalu(
rtc::CopyOnWriteBuffer rtp_payload) {
// Skip the single NALU header (payload header), aggregated packet case will
@ -122,6 +128,10 @@ absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessApOrSingleNalu(
case H265::NaluType::kIdrNLp:
case H265::NaluType::kCra:
case H265::NaluType::kRsvIrapVcl23:
// Mark IRAP(Intra Random Access Point) frames as key frames. Their NALU
// types are in the range of BLA_W_LP (16) to RSV_IRAP_VCL23 (23),
// inclusive.
// https://datatracker.ietf.org/doc/html/rfc7798#section-3.1.1
parsed_payload->video_header.frame_type =
VideoFrameType::kVideoFrameKey;
ABSL_FALLTHROUGH_INTENDED;
@ -170,6 +180,8 @@ absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> ProcessApOrSingleNalu(
return parsed_payload;
}
// Fragmentation Unit (FU) structure:
// https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3
absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuNalu(
rtc::CopyOnWriteBuffer rtp_payload) {
if (rtp_payload.size() < kH265FuHeaderSizeBytes + kH265NalHeaderSizeBytes) {
@ -204,6 +216,8 @@ absl::optional<VideoRtpDepacketizer::ParsedRtpPayload> ParseFuNalu(
if (original_nal_type >= H265::NaluType::kBlaWLp &&
original_nal_type <= H265::NaluType::kRsvIrapVcl23) {
// IRAP picture.
// https://datatracker.ietf.org/doc/html/rfc7798#section-3.1.1
parsed_payload->video_header.frame_type = VideoFrameType::kVideoFrameKey;
} else {
parsed_payload->video_header.frame_type = VideoFrameType::kVideoFrameDelta;