Convert decoder.c to C++