av_hwaccel_next() by Gwenole Beauchesne.