Closed cubicibo closed 6 months ago
@cubicibo not sure about this: in the below links, dts should be zero. If you can find a reference to a more official source...
https://video.stackexchange.com/questions/16261/split-pgs-subtitles-sup-file
Hi @jcdr428, unfortunately this is a widespread misconception originating from DGDemux/eac3to suites. Many files were produced with these programs that always set DTS to zero, and people got the impression the field is never used.
However, when drmpeg designed the 'PG' SUP file format, he made sure to convey both PTS and DTS (truncated from 33 to 32 bits). Since the DTS is irrelevant for software players, it has been discarded by some tools like DGDemux. If the SUP file is muxed back to a transport stream, the incorrect DTS value will cause issue to some decoders. It can range from PTS-DTS difference being larger than one second, memory overruns in the PG decoder (too many PCS buffered at once, overwriting ODS when it should be read-only). Or not enough decoding time if tsMuxer uses PTS for scheduling when DTS is zero.
If you take professionally authored discs and analyze the transport stream, you will see actual DTS values to ensure decoder memory and bandwidth are dully respected. Here is a good PG stream but with DTS=0 played on PS3. As you can see, the effect is catastrophic. https://github.com/justdan96/tsMuxer/assets/55701024/a634d8c4-a654-4d8a-874c-a8523f6d9d60
When muxing, tsMuxer and other professional muxers uses the "not permitted" case of PTS=DTS to know when a PES packet should have PTS_DTS_Flags equal to 0b10 or 0b11: https://github.com/justdan96/tsMuxer/blob/94cafe7244213870aaab37035c827ef839a15929/tsMuxer/tsMuxer.cpp#L609C1-L612C51
This proposed code change makes tsMuxer muxing and demuxing operations bijective for PG streams.
Ok, I've pushed the commit.
This is a tiny change in demuxing. I think this is more logical than a sporadically null DTS in the output .SUP file.
PTS_DTS_flags=0b10
suggests PTS=DTS, rather than DTS=0.0b10 == PTS_DTS_flags
candidates rather than look at the segment type and do guess work, as DTS=0 can be a valid value, while PTS and DTS should never be equal in a TS packet.