Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Based on work by Kostya Shishkov <kostya.shishkov@gmail.com>.