patch by Fernando Tarín (icemanf gmail com) with some fixes by me (this patch still needs some review; note the added FIXME comment..) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22569 b3059339-0415-0410-9bf9-f77b7e298cf2