The StartHunk logic was flawed and while working with CHD files before v5 didn't work for v5 (and above).
The extraframes logic did work in some cases (read 3 track CHDv5) but didn't work in all cases and was merely a hack in retrospective.
Thanks to the comment of @flyinghead (see also b6c2508922 (diff-cb507bb17d74342aa45b6e4d10d607af)) the logic is now correct and works for v4 and v5 files.
If the frame count is not dividable by 4, there are extra frames added to keep a padding.
This is true for F355 (450 frames -> 2 extra frames) and others.
Also move CD_TRACK_PADDING to chd.cpp to work around problems with including from C and C++.