merged both implementations. added x265 support