Improved matching algorithm to avoid unnecessary transcoding 

based on
https://github.com/ps3mediaserver/ps3mediaserver/commit/7ccb5762b541b4f6d650aa7a6717c1168deb1e17