* [FFmpeg-devel] [PATCH] libavformat/rtpenc_h264_hevc: Use original TID value from NAL unit header in HEVC FU packets
@ 2025-11-21 4:37 树 via ffmpeg-devel
2025-11-24 2:29 ` [FFmpeg-devel] " Zhao Zhili via ffmpeg-devel
0 siblings, 1 reply; 2+ messages in thread
From: 树 via ffmpeg-devel @ 2025-11-21 4:37 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: 树
Dear FFmpeg developers,
Currently, when fragmenting HEVC NAL units for RTP transmission, the code
forces the Temporal ID (TID) field to 1 in the FU payload header, regardless
of the original TID value in the NAL unit header. This violates RFC 7798
section 4.4.3 which states that "the fields F, LayerId, and TID MUST be equal
to the fields F, LayerId, and TID, respectively, of the fragmented NAL unit."
This patch modifies the HEVC fragmentation unit handling to preserve the
original TID value from the NAL unit header, ensuring standards compliance
and proper temporal layer signaling.
## Problem Description
In the current implementation, HEVC FU packets always set TID=1, which:
- Violates RFC 7798 requirements
- Breaks temporal scalability information
- May cause compatibility issues with standards-compliant decoders
## Solution
Extract the original TID value (bits 0-2 of the second NAL header byte)
and use it in the FU payload header instead of hardcoding to 1.
## Patch
The change is minimal and focused:
--- a/libavformat/rtpenc_h264_hevc.c
+++ b/libavformat/rtpenc_h264_hevc.c
@@ -138,7 +138,7 @@ static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last
* TID = 1
*/
s->buf[0] = 49 << 1;
- s->buf[1] = 1;
+ s->buf[1] = buf[1] & 0x7;
## Testing
- Verified with HEVC streams containing various TID values
- Confirmed RFC 7798 compliance
- No regression in existing functionality
## Impact
This change improves standards compliance while maintaining backward
compatibility for streams where TID=1.
Signed-off-by: shenshuyu <shenshuyu1991@qq.com>
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FFmpeg-devel] Re: [PATCH] libavformat/rtpenc_h264_hevc: Use original TID value from NAL unit header in HEVC FU packets
2025-11-21 4:37 [FFmpeg-devel] [PATCH] libavformat/rtpenc_h264_hevc: Use original TID value from NAL unit header in HEVC FU packets 树 via ffmpeg-devel
@ 2025-11-24 2:29 ` Zhao Zhili via ffmpeg-devel
0 siblings, 0 replies; 2+ messages in thread
From: Zhao Zhili via ffmpeg-devel @ 2025-11-24 2:29 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: 树, Zhao Zhili
> On Nov 21, 2025, at 12:37, 树 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> wrote:
>
> Dear FFmpeg developers,
>
>
> Currently, when fragmenting HEVC NAL units for RTP transmission, the code
> forces the Temporal ID (TID) field to 1 in the FU payload header, regardless
> of the original TID value in the NAL unit header. This violates RFC 7798
> section 4.4.3 which states that "the fields F, LayerId, and TID MUST be equal
> to the fields F, LayerId, and TID, respectively, of the fragmented NAL unit."
>
>
> This patch modifies the HEVC fragmentation unit handling to preserve the
> original TID value from the NAL unit header, ensuring standards compliance
> and proper temporal layer signaling.
>
>
> ## Problem Description
> In the current implementation, HEVC FU packets always set TID=1, which:
> - Violates RFC 7798 requirements
> - Breaks temporal scalability information
> - May cause compatibility issues with standards-compliant decoders
>
>
> ## Solution
> Extract the original TID value (bits 0-2 of the second NAL header byte)
> and use it in the FU payload header instead of hardcoding to 1.
>
>
> ## Patch
> The change is minimal and focused:
>
>
> --- a/libavformat/rtpenc_h264_hevc.c
> +++ b/libavformat/rtpenc_h264_hevc.c
> @@ -138,7 +138,7 @@ static void nal_send(AVFormatContext *s1, const uint8_t *buf, int size, int last
> * TID = 1
> */
> s->buf[0] = 49 << 1;
> - s->buf[1] = 1;
> + s->buf[1] = buf[1] & 0x7;
Corrupted text. Please note qq email web client doesn’t support plain text.
Could you send a PR on https://code.ffmpeg.org/FFmpeg/FFmpeg?
>
>
> ## Testing
> - Verified with HEVC streams containing various TID values
> - Confirmed RFC 7798 compliance
> - No regression in existing functionality
>
>
> ## Impact
> This change improves standards compliance while maintaining backward
> compatibility for streams where TID=1.
>
>
> Signed-off-by: shenshuyu <shenshuyu1991@qq.com>
> _______________________________________________
> ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
> To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-24 2:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-21 4:37 [FFmpeg-devel] [PATCH] libavformat/rtpenc_h264_hevc: Use original TID value from NAL unit header in HEVC FU packets 树 via ffmpeg-devel
2025-11-24 2:29 ` [FFmpeg-devel] " Zhao Zhili via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git