vdpau: factor out common end-of-frame handling