Repository navigation
修复 MPEG-1/2 AU 边界处理并强化 PES/TS 输入安全 - #399
Open
alexliyu7352 wants to merge 18 commits into
Open
alexliyu7352 wants to merge 18 commits into
alexliyu7352 wants to merge 18 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
该 PR 聚焦于提升 MPEG TS/PS 解复用在异常/分片输入下的健壮性与安全性,并补齐跨 PES 的 MPEG-1/2 视频 AU(Access Unit)边界识别与 flush 行为,同时通过新增回归测试与 CI 覆盖来防止回归。
Changes:
- 在
pes_packet/TS demux 路径中引入更严格的输入校验、容量上限与跨 PES 状态管理,增强对非法 TS/分片 PES header/continuity/discontinuity 等情况的处理。 - 增强 MPEG-1/2 视频跨 PES 的 AU 边界识别与 codec 探测/transition 逻辑,并修复有限长度 H.26x PES 的 flush 行为。
- 新增大规模回归测试并将其接入 GitHub Actions 的 PR 触发构建。
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libmpeg/test/mpeg-packet-test.cpp | 新增覆盖跨 PES、codec 探测、TS 异常输入与 flush 的回归测试集合,并支持在 CI 中单独编译运行。 |
| libmpeg/source/mpeg-ts-internal.h | 为 TS demux 引入每路 stream 的 PES 解析状态结构(ts_pes_state_t),用于跨 TS 包/跨 PES 维护 header 与 payload 进度。 |
| libmpeg/source/mpeg-ts-h264.c | 修复 codec verify 在样本不足时的越界读取风险(增加 count > 0 防护)。 |
| libmpeg/source/mpeg-ts-dec.c | 强化 adaptation field 解析边界检查;重构 PES header 解析为可跨包缓存的状态机;补强 continuity/TEI/discontinuity 等异常处理与 flush 语义。 |
| libmpeg/source/mpeg-ps-dec.c | 规范化 demux 回调返回值语义,避免与“消耗字节数”的非负返回冲突。 |
| libmpeg/source/mpeg-pmt.c | 统一释放与清理 PMT stream 状态(包含新增的 stream_states)。 |
| libmpeg/source/mpeg-pes.c | 修复 MPEG-1 PES header 解析在分片/STD 字段处理上的健壮性与 release 行为。 |
| libmpeg/source/mpeg-pes-internal.h | 扩展 packet_t 以承载 MPEG-1/2 AU 解析所需状态,并对外声明 pes_packet_discontinuity。 |
| libmpeg/source/mpeg-packet.c | 重构 packet buffer 扩容与上限校验;新增 MPEG-1/2 AU 边界解析;改进 RESERVED codec 探测与跨 PES 证据保留;加强输入契约校验与错误原子性。 |
| .github/workflows/ccpp.yml | 将 CI 从仅 push 扩展到 pull_request,并增加 libmpeg packet 回归测试编译+运行步骤。 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+255
to
+260
| packet_length = (uint16_t)(((uint16_t)header[4] << 8) | header[5]); | ||
| mpeg_bits_init(&reader, header, PES_HEADER_MIN_SIZE + header[8]); | ||
| prefix = mpeg_bits_readn(&reader, 3); | ||
| pes->sid = mpeg_bits_read8(&reader); | ||
| r = pes_read_header(pes, &reader); | ||
| if (MPEG_ERROR_OK != r || 0x000001 != prefix) |
Contributor
Author
There was a problem hiding this comment.
代码本来就会在新 PES 没有时间戳时清空旧的 PTS/DTS,不会继承上一帧时间戳
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现有 MPEG 解复用在跨 PES 的 MPEG-1/2 视频数据、分片 PES header、有限长度 H.26x PES 以及异常 TS 输入下,可能出现:
本pr的改动如下: