Description
Modern standards allow a frame to predict its content temporally from both past and future (B-frames). Encoded chunks are usually stored in encoding/decoding order which may be different from presentation order. VideoFrames
are given to VideoEncoder
in presentation order which may reorder them before coding and output encoded video chunks in decoding order. Similarly, encoded chunks are given in decoding order to VideoDecoder.
What if VideoDecoder
calls VideoDecoderOutputCallback
as soon as a video frame decoding has finished, i.e. it gives VideoFrames to VideoDecoderOutputCallback in decoding order, not presentation order. In use cases like video playback Web App then needs to reorder the VideoFrame into presentation order. Although this increases a bit Web App complexity, it has several advantages:
- UA does not need to maintain a queue of decoded
VideoFrames
that will be given to the Web App sometimes later after other frames. - VideoFrames are given to Web App as soon as possible which gives the Web App more time to do some processing to frames before displaying them.
- Useful if the Web App is in full control of the synchronization and displaying the frames
How about adding decodingSequence
and presentationSequence
like -
interface EncodedVideoChunk {
...
readonly attribute unsigned long decodingSequence;
};
[Exposed=(Window)]
interface VideoFrame {
...
readonly attribute unsigned long presentationSequence;
};
In EncodedVideoChunk
decodingSequence would denote the coded order and be filled by the Web App before giving the chunk to VideoDecoder
. VideoDecoder
would fill presentationSequence of VideoFrame
before calling OutputCallback
.
There has been similar discussions in #7.