summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.h3
-rw-r--r--libhb/demuxmpeg.c5
-rw-r--r--libhb/internal.h2
-rw-r--r--libhb/reader.c5
-rwxr-xr-xlibhb/stream.c7
5 files changed, 19 insertions, 3 deletions
diff --git a/libhb/common.h b/libhb/common.h
index 018055894..a5cfcf493 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -452,7 +452,8 @@ 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 d92798a40..a30a15c59 100644
--- a/libhb/demuxmpeg.c
+++ b/libhb/demuxmpeg.c
@@ -137,7 +137,7 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state
{
dts = pts;
}
- if ( state )
+ 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
@@ -149,9 +149,10 @@ int hb_demux_ps( hb_buffer_t * buf_ps, hb_list_t * list_es, hb_psdemux_t* state
// 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 )
+ 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;
}
diff --git a/libhb/internal.h b/libhb/internal.h
index 5f04e3852..e9828fdb9 100644
--- a/libhb/internal.h
+++ b/libhb/internal.h
@@ -108,6 +108,8 @@ hb_work_object_t * hb_codec_encoder( int );
typedef struct {
int64_t last_scr; /* unadjusted SCR from most recent pack */
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;
int hb_demux_ps( hb_buffer_t * ps_buf, hb_list_t * es_list, hb_psdemux_t * );
diff --git a/libhb/reader.c b/libhb/reader.c
index 75fd1b4fa..62102c243 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -209,6 +209,7 @@ 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 )
{
@@ -381,6 +382,10 @@ static void ReaderFunc( void * _r )
}
hb_log( "reader: done. %d scr changes", r->demux.scr_changes );
+ if ( r->demux.dts_drops )
+ {
+ hb_log( "reader: %d drops because DTS out of range", r->demux.dts_drops );
+ }
free( r );
_r = NULL;
diff --git a/libhb/stream.c b/libhb/stream.c
index 5c8f4f4f7..dd5c7090d 100755
--- a/libhb/stream.c
+++ b/libhb/stream.c
@@ -466,6 +466,13 @@ hb_stream_t * hb_stream_open( char *path, hb_title_t *title )
d->ts_buf[i] = malloc( HB_DVD_READ_BUFFER_SIZE );
}
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;
}