This is cherrypicked from libav commit 85ad5ea72c. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
85ad5ea72c