Updated for new version of EncodeFrame