This is cherrypicked from libav commit 07b5136c48. Signed-off-by: Martin Storsjö <martin@martin.st>
07b5136c48