Decompression timestamp
lastmod 2024-05-24created 2024-05-244 edits
A timestamp for decoding order.
PTS vs DTS
See Presentation timestamp#PTS vs DTS.
Detailed explanation
- It's Elemental – Feedback and levels of description, or: What MPEG2 compression can teach you about cybernetics and epistemology
- Apple TV: Using DVDs and other Video Sources
- What is DTS (Decoding Time Stamp)?
See Group of pictures (GoP) for details on I, P, and B frames.
To understand what DTS is, we first need to look at MPEG-1 video. MPEG-1 is a lossy compression standard for video and audio.
The video part is divided into four types of frames.
- I-frames - Intra frame. Also called a keyframe. Holds the base information.
- P-frames - Predicted frame. Also called an inter-frame. A P-frame contains only the parts that changed relative to the previous frame. So there must be a ‘previous’ frame, which is called the anchor frame. The anchor frame can be either an I-frame or a P-frame.
- B-frames - bidirectional-frame. While a P-frame stores only the delta relative to the previous frame, a B-frame's information can draw on the frame that comes next as well as the previous frame. So it has 2 anchor frames.
- D-frames - Reportedly not used in later video standards, so skipped.
The following example makes it easy to understand how an I-frame and a P-frame draw the picture.
Droppedimage_2_thumb.png
As the figure above (source) shows, rather than keeping every full frame, the unchanging background is stored in the I-frame, and only the falling person and the waterfall need to be redrawn.
So what is a B-frame? A B-frame is a way to raise the compression ratio a bit further.
Because it can mark the parts that changed relative to the preceding anchor, and also mark what the prior state was relative to the following anchor, it can be said to express more information with less data.
Ipb_frame_example_thumb.jpg
Anyway, the compression ratio can be said to improve in the order shown in the figure above (source).
Now, finally, what is DTS?
DTS is needed because of the B-frame. If the stream consisted only of I-frame and P-frame without any B-frame, you could simply decode in order. But to decode a B-frame, not only the preceding anchor frame but also the following anchor frame must be decoded first. In other words, the display order and the decoding order differ, and DTS was created to handle that.
If frames must be displayed as above, the actual decoding order
becomes this.
The value that represents this order is the Decoding Time Stamp. For that reason, it is said to be common to encode in DTS order from the start.
When it's not needed
If you use a high-level library such as FFmpeg, you receive the full image result for each frame (i.e., already decoded using the DTS information), so in this case you only need to look at the PTS.