diff options
-rw-r--r-- | libhb/common.h | 2 | ||||
-rw-r--r-- | libhb/demuxmpeg.c | 39 | ||||
-rw-r--r-- | libhb/internal.h | 2 | ||||
-rw-r--r-- | libhb/reader.c | 1 | ||||
-rwxr-xr-x | libhb/stream.c | 7 |
5 files changed, 18 insertions, 33 deletions
diff --git a/libhb/common.h b/libhb/common.h index 2545e2d50..5da21214e 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -482,8 +482,6 @@ struct hb_title_s int video_id; /* demuxer stream id for video */ int video_codec; /* worker object id of video codec */ int video_codec_param; /* codec specific config */ - int flaky_clock; /* can lose reference clock */ - /* (for over-the-air transport streams) */ const char *video_codec_name; int video_bitrate; const char *container_name; diff --git a/libhb/demuxmpeg.c b/libhb/demuxmpeg.c index 15ea9b73f..9e0a952ee 100644 --- a/libhb/demuxmpeg.c +++ b/libhb/demuxmpeg.c @@ -39,6 +39,7 @@ static inline void check_mpeg_scr( hb_psdemux_t *state, int64_t scr, int tol ) if ( scr_delta > 90*tol || scr_delta < -90*10 ) { ++state->scr_changes; + state->last_pts = -1; } state->last_scr = scr; } @@ -143,26 +144,6 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state { dts = pts; } - if ( state && state->flaky_clock ) - { - // 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 < -300 * 90000LL || fdelta > 300 * 90000LL ) - { - // packet too far behind or ahead of its clock reference - ++state->dts_drops; - pos = pes_packet_end; - continue; - } - } } pos = pes_header_end; @@ -228,7 +209,7 @@ int hb_demux_ts( hb_buffer_t *buf_ps, hb_list_t *list_es, hb_psdemux_t *state ) check_mpeg_scr( state, buf_ps->stop, 300 ); buf_ps->stop = -1; } - if ( buf_ps->renderOffset >= 0 ) + if ( buf_ps->start >= 0 ) { // Program streams have an SCR in every PACK header so they // can't lose their clock reference. But the PCR in Transport @@ -239,13 +220,27 @@ int hb_demux_ts( hb_buffer_t *buf_ps, hb_list_t *list_es, hb_psdemux_t *state ) // 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 = buf_ps->renderOffset - state->last_scr; + int64_t fdelta = buf_ps->start - state->last_scr; if ( fdelta < -300 * 90000LL || fdelta > 300 * 90000LL ) { // packet too far behind or ahead of its clock reference ++state->dts_drops; return 1; } + if ( state->last_pts >= 0 ) + { + fdelta = buf_ps->start - state->last_pts; + if ( fdelta < -5 * 90000LL || fdelta > 5 * 90000LL ) + { + // Packet too far from last. This may be a NZ TV broadcast + // as they like to change the PCR without sending a PCR + // update. Since it may be a while until they actually tell + // us the new PCR use the PTS as the PCR. + ++state->scr_changes; + state->last_scr = buf_ps->start; + } + } + state->last_pts = buf_ps->start; } } diff --git a/libhb/internal.h b/libhb/internal.h index 19a3bd2b3..fa3fe86f6 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -147,8 +147,8 @@ hb_work_object_t * hb_codec_encoder( int ); **********************************************************************/ typedef struct { int64_t last_scr; /* unadjusted SCR from most recent pack */ + int64_t last_pts; /* last pts we saw */ int scr_changes; /* number of SCR discontinuities */ - int flaky_clock; /* try to compensate for PCR drops */ int dts_drops; /* number of drops because DTS too far from SCR */ } hb_psdemux_t; diff --git a/libhb/reader.c b/libhb/reader.c index be7a9aecc..a820b3c11 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -245,7 +245,6 @@ static void ReaderFunc( void * _r ) list = hb_list_init(); hb_buffer_t *ps = hb_buffer_init( HB_DVD_READ_BUFFER_SIZE ); - r->demux.flaky_clock = r->title->flaky_clock; while( !*r->die && !r->job->done ) { diff --git a/libhb/stream.c b/libhb/stream.c index 71e9cb812..f95d3518c 100755 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -518,13 +518,6 @@ hb_stream_t * hb_stream_open( char *path, hb_title_t *title ) d->ts_buf[i]->size = 0; } hb_stream_seek( d, 0. ); - - if ( d->packetsize == 188 ) - { - // Assume that an over-the-air transport stream can lose PCR - // packets and try to filter out the timing inconsistencies. - title->flaky_clock = 1; - } } return d; } |