YFrameHSize/UVFrameHSize values are compared with GetPlanePitch().
But YFrameHSize/UVFrameHSize are derived from m_iWidth, not pitch. Pitch of subsequent frames can be greater than width and it is quite normal.
So, YFrameHSize/UVFrameHSize values should be compared with width value(s).
For more complete information about compiler optimizations, see our Optimization Notice.