synced patch with current FFmpeg svn