Add an API to do the decoding externally (in hardware)

Open Steve Lhomme requested to merge robUx4/dav1d:hw-decode/2 into master

This is primarily to be able to do DXVA decoding and fallback gracefully to software decoding without having to restart a whole decoder, which may lose pipelined data during the restart.

This is based on a branch from Matthew Wozniak with all the DXVA parts stripped out (they have been added to a VLC branch). Only some callbacks remain to bypass the software decoding parts.

DXVA is a rather low level decoder so needs a lot of parsed information from the bitstream. This is all available in dav1d. Other hardware decoders may not need all these info but should also work fine with these set all callbacks. Or maybe they would need the full unparsed bitstream, in which case other (optional) callbacks may be used elsewhere in the code.

The goal is to be able to use dav1d and hardware decoding at the same time. Right now it's not possible to use dav1d and hardware decoding found in libavcodec, these decoders are mutually exclusive. To be able to merge them, lavc will likely need the same callbacks anyway.

This code has been verified to work in VLC in this branch with NVIDIA and Intel hardware. More in-depth testing is needed, especially enabling multithread which is technically possible, and would benefit the software callback a lot.

v6: rebased for the API version update and fixed the max_frame_delay check with hardware decoding (value 0 is also allowed)

v7: set the default external_decoder to NULL otherwise it's uninitialized (ie not NULL)

Edited by Steve Lhomme

Merge request reports