diff options
author | van <[email protected]> | 2008-09-17 17:06:38 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-09-17 17:06:38 +0000 |
commit | 369e9ada0dae074d3d4d52f0274eb0520bf3569f (patch) | |
tree | 060e1c6422d5fd2e94e0140d3e18e010ff23a1c9 /libhb/demuxmpeg.c | |
parent | fc83d1358778a65830db058a337c07aa2aa1c4eb (diff) |
Filter timestamps to prevent missing/incorrect Transport Stream PCRs messing up A/V sync.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1712 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/demuxmpeg.c')
-rw-r--r-- | libhb/demuxmpeg.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libhb/demuxmpeg.c b/libhb/demuxmpeg.c index 51292eb43..d92798a40 100644 --- a/libhb/demuxmpeg.c +++ b/libhb/demuxmpeg.c @@ -137,6 +137,25 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state { dts = pts; } + if ( state ) + { + // Program streams have an SCR in every PACK header so they + // can't lose their clock reference. But the PCR in Transport + // streams is typically on <.1% of the packets. If a PCR + // packet gets lost and it marks a clock discontinuity then + // the data following it will be referenced to the wrong + // clock & introduce huge gaps or throw our A/V sync off. + // We try to protect against that here by sanity checking + // timestamps against the current reference clock and discarding + // packets where the DTS is "too far" from its clock. + int64_t fdelta = dts - state->last_scr; + if ( fdelta < -5000 * 90 || fdelta > 5000 * 90 ) + { + // packet too far behind or ahead of its clock reference + pos = pes_packet_end; + continue; + } + } } pos = pes_header_end; |