summaryrefslogtreecommitdiffstats
path: root/libhb/demuxmpeg.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-05-13 10:27:36 +0000
committerjstebbins <[email protected]>2014-05-13 10:27:36 +0000
commit4f26df992773986e3134907aabca1efe216c7a59 (patch)
tree6973bd56e6519c7a5836c156bfec2910c356a7f6 /libhb/demuxmpeg.c
parentfbef8a53808d5927abb8bdb1a99fac82d9901505 (diff)
demux: fix problem with widely spaced SCRs
Fixes this bug report https://forum.handbrake.fr/viewtopic.php?f=12&t=30032 Split MPEG demuxer into TS demuxer and PS demuxer to allow using different PCR/SCR delta tolerance in each scenario. We were using a PCR/SCR delta tolerance that was a bit of a compromise between the max allowed by the specification for TS vs PS streams. But the spec for TS PCR is 100ms and the spec for PS SCR is 700ms, so we risked false detection of discontinuities in PS. In PS streams that pack multiple frames into one PES packet, the detection of a discontinuity causes recalculation of an scr offset which jumps around wildly. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6183 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/demuxmpeg.c')
-rw-r--r--libhb/demuxmpeg.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libhb/demuxmpeg.c b/libhb/demuxmpeg.c
index ded5ad47b..5a51f42c2 100644
--- a/libhb/demuxmpeg.c
+++ b/libhb/demuxmpeg.c
@@ -102,7 +102,7 @@ void hb_demux_dvd_ps( hb_buffer_t * buf, hb_list_t * list_es, hb_psdemux_t* stat
((uint64_t)(d[pos+2] & 3) << 13) |
((uint64_t)(d[pos+3]) << 5) |
(d[pos+4] >> 3);
- check_mpeg_scr( state, scr, 300 );
+ check_mpeg_scr( state, scr, 700 );
}
pos += 9; /* pack_header */
@@ -245,7 +245,8 @@ void hb_demux_dvd_ps( hb_buffer_t * buf, hb_list_t * list_es, hb_psdemux_t* stat
// stripped off and buf has all the info gleaned from them: id is set,
// start contains the pts (if any), renderOffset contains the dts (if any)
// and stop contains the pcr (if it changed).
-void hb_demux_mpeg( hb_buffer_t *buf, hb_list_t *list_es, hb_psdemux_t *state )
+void hb_demux_mpeg(hb_buffer_t *buf, hb_list_t *list_es,
+ hb_psdemux_t *state, int pcr_tolerance)
{
while ( buf )
{
@@ -266,7 +267,7 @@ void hb_demux_mpeg( hb_buffer_t *buf, hb_list_t *list_es, hb_psdemux_t *state )
if ( buf->s.pcr >= 0 )
{
// we have a new pcr
- check_mpeg_scr( state, buf->s.pcr, 300 );
+ check_mpeg_scr( state, buf->s.pcr, pcr_tolerance );
buf->s.pcr = AV_NOPTS_VALUE;
// Some streams have consistantly bad PCRs or SCRs
// So filter out the offset
@@ -337,6 +338,19 @@ void hb_demux_mpeg( hb_buffer_t *buf, hb_list_t *list_es, hb_psdemux_t *state )
}
}
+void hb_demux_ts(hb_buffer_t *buf, hb_list_t *list_es, hb_psdemux_t *state)
+{
+ // Distance between PCRs in TS is up to 100ms, but we have seen
+ // streams that exceed this, so allow up to 300ms.
+ hb_demux_mpeg(buf, list_es, state, 300);
+}
+
+void hb_demux_ps(hb_buffer_t *buf, hb_list_t *list_es, hb_psdemux_t *state)
+{
+ // Distance between SCRs in PS is up to 700ms
+ hb_demux_mpeg(buf, list_es, state, 700);
+}
+
// "null" demuxer (makes a copy of input buf & returns it in list)
// used when the reader for some format includes its own demuxer.
// for example, ffmpeg.
@@ -370,4 +384,4 @@ void hb_demux_null( hb_buffer_t * buf, hb_list_t * list_es, hb_psdemux_t* state
}
}
-const hb_muxer_t hb_demux[] = { hb_demux_dvd_ps, hb_demux_mpeg, hb_demux_null };
+const hb_muxer_t hb_demux[] = { hb_demux_dvd_ps, hb_demux_ts, hb_demux_ps, hb_demux_null };