| 1 |
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation |
| 2 |
.. |
| 3 |
.. SPDX-License-Identifier: CC-BY-4.0 |
| 4 |
|
| 5 |
============== |
| 6 |
Video Decoding |
| 7 |
============== |
| 8 |
|
| 9 |
The :term:`DECODE` class of functions take a compressed bitstream as input and |
| 10 |
converts it to raw frames as output. |
| 11 |
|
| 12 |
DECODE processes only pure or elementary video streams with the exception of |
| 13 |
AV1/VP9/VP8 decoders, which accept the IVF format. The library can process |
| 14 |
bitstreams that reside in an IVF container but cannot process bitstreams that |
| 15 |
reside in any other container format, such as MP4 or MPEG. |
| 16 |
|
| 17 |
The application must first demultiplex the bitstreams. Demultiplexing |
| 18 |
extracts pure video streams out of the container format. The application can |
| 19 |
provide the input bitstream as one complete frame of data, a partial frame (less |
| 20 |
than one complete frame), or as multiple frames. If only a partial frame is |
| 21 |
provided, DECODE internally constructs one frame of data before decoding it. |
| 22 |
|
| 23 |
The time stamp of a bitstream buffer must be accurate to the first byte of the |
| 24 |
frame data. For H.264 the first byte of the frame data comes from the |
| 25 |
NAL unit in the video coding layer. For MPEG-2 or VC-1 the first byte of the |
| 26 |
frame data comes from the picture header. DECODE passes the time stamp to the |
| 27 |
output surface for audio and video multiplexing or synchronization. |
| 28 |
|
| 29 |
Decoding the first frame is a special case because DECODE does not provide |
| 30 |
enough configuration parameters to correctly process the bitstream. DECODE |
| 31 |
searches for the sequence header (a sequence parameter set in H.264 or a |
| 32 |
sequence header in MPEG-2 and VC-1) that contains the video configuration |
| 33 |
parameters used to encode subsequent video frames. The decoder skips any |
| 34 |
bitstream prior to the sequence header. In the case of multiple sequence headers |
| 35 |
in the bitstream, DECODE adopts the new configuration parameters, ensuring |
| 36 |
proper decoding of subsequent frames. |
| 37 |
|
| 38 |
DECODE supports repositioning of the bitstream at any time during decoding. |
| 39 |
Because there is no way to obtain the correct sequence header associated with |
| 40 |
the specified bitstream position after a position change, the application must |
| 41 |
supply DECODE with a sequence header before the decoder can process the next |
| 42 |
frame at the new position. If the sequence header required to correctly decode |
| 43 |
the bitstream at the new position is not provided by the application, DECODE |
| 44 |
treats the new location as a new “first frame” and follows the procedure for |
| 45 |
decoding first frames. |