multithreaded encoder