In transform_motion_decompose, successive quaternion pairs are checked to be aligned such that their interpolation is rotation through the shortest angle between them. If not, the first in the pair is flipped. This can cause problems for sequences of more than 2 quarternions, since flipping the first in a pair might misalign the previously pair, if unlucky.
Instead, this change flips the second in the pair, which is safe when iterating forwards.
This seems to fix both T66529 and T70694. I've tested this change on the test files in both tasks and I no longer see the rendering artifacts.