avformat/avienc: factor frame skip code out