Skip to content

Tolerate FU/FU-A with both S and E bits set#131

Merged
scottlamb merged 2 commits into
scottlamb:mainfrom
danieltwagner:fix-invalid-fu-header
Mar 29, 2026
Merged

Tolerate FU/FU-A with both S and E bits set#131
scottlamb merged 2 commits into
scottlamb:mainfrom
danieltwagner:fix-invalid-fu-header

Conversation

@danieltwagner

Copy link
Copy Markdown
Contributor

On my IMX415-based SSC378DE (Infinity6c family) OpenIPC camera I have observed intermittent packets that have both start and end bits set, both for H.264 and H.265.

This PR proposes to warn once when these are encountered and to otherwise struggle on, treating them as a complete NAL.
Previously this caused an Invalid FU-A header c1 / Invalid FU header c1 error and stream teardown.

Before: H.265 8/8 runs failed within 3–69s; H.264 intermittent as FU-A errors occur less frequently than with H.265.
After: 3/3 H.265 × 120s and 3/3 H.264 × 180s runs complete cleanly, all frames decode without error.

@scottlamb scottlamb left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the nice report, test, and fix! One comment below.

Comment thread src/codec/h264.rs Outdated
initial_nal_header: nal_header,
cur_nal,
});
if end {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we hoist this end block to after the match rather than duplicate it for the start vs non-start cases? (same in h265.rs)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly; is this what you had in mind?

Comment thread src/codec/h264.rs
});
}
} else if mark {
return Err("FU-A has MARK and no END".into());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was dead, shadowed by the conditional in L496 ("FU-A pkt with MARK && !END")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; nice catch

Comment thread src/codec/h265.rs
nal.next_piece_idx = pieces;
access_unit.in_fu = false;
} else if mark {
return Err("FU has MARK and no END".into());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this to be similarly shadowed by "FU pkt with MARK && !END" (L389)

@danieltwagner danieltwagner requested a review from scottlamb March 28, 2026 23:28
@scottlamb scottlamb merged commit e1c0bbf into scottlamb:main Mar 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants