tsdemux: Sudden jump in PTS when there is a backward jump in PCR
Submitted by parithi
Link to original bug (#787085)
Description
With UDP input, whenever there is a backward jump in PCR, PTS calculation is going wrong.
In TS demuxer PTS is calculated using below equation
out_PTS = PTS + pcr_offset + base_time - base_pcrtime;
whenever there is a backward jump in PCR is pcr_offset is updated with the deviation between base_pcrtime and current pcr time. And the same offset is added with PTS also. This sudden jump in PTS is chocking the pipeline.
Pipelines and buffer time stamps
gst-launch-1.0 udpsrc port=8000 ! tsdemux ! checksumsink
0:00:30.598786471 680c47336866cc84763d57f70f6da3fac8883fd9
0:00:30.678786471 494de7e78e362b8094a79e8845ef06248d83098f
9:23:15.335157152 4db283bf6f1afb771ab17bfd390bccd76e848f4b -- sudden jump
0:00:30.796141979 c37fa545074d1a06f58e94fe817f041f81e036ab
0:00:30.756141835 7519205aeaa27e312616bcd86c9f6f143a61b650
0:00:30.836141835 4d78efa7f0080a8cbb38aac2ca005f15e8d648ec
gst-launch-1.0 udpsrc port=8000 ! tsdemux ! h264parse ! avdec_h264 ! checksumsink --gst-debug=3
0:00:10.138379707 6976 0x810400 WARN videodecoder gstvideodecoder.c:2775:gst_video_decoder_prepare_finish_frame:<avdec_h264-0>
decreasing timestamp (0:00:10.692303114 < 9:22:52.969321645)
9:22:52.969321645 2eabf26677ebc0f85852b860d07f8ef4d1a93b17
0:00:10.189489982 6976 0x810400 WARN videodecoder gstvideodecoder.c:2775:gst_video_decoder_prepare_finish_frame:<avdec_h264-0>
decreasing timestamp (0:00:10.732303113 < 9:22:52.969321645)
9:22:52.969321645 1e076ae62acb9aaa69c5a149138e2c9968ca9545
0:00:10.235837073 6976 0x810400 WARN videodecoder gstvideodecoder.c:2775:gst_video_decoder_prepare_finish_frame:<avdec_h264-0>
decreasing timestamp (0:00:10.812303113 < 9:22:52.969321645)
9:22:52.969321645 ab92e908e19b1ac48697fa73baa695a587a39e24
0:00:10.287201163 6976 0x810400 WARN videodecoder gstvideodecoder.c:2775:gst_video_decoder_prepare_finish_frame:<avdec_h264-0>
decreasing timestamp (0:00:10.852303113 < 9:22:52.969321645)
Version: 1.12.1