diff options
author | jstebbins <[email protected]> | 2015-04-22 21:59:31 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-04-22 21:59:31 +0000 |
commit | ecb77662da768b8011be27c68725eea10c62c570 (patch) | |
tree | dcd9fd8859ae8986d173ddcc6fe644c9e9782042 | |
parent | ddcecd907b532f867a5c7a1aa89ea6909205caab (diff) |
demuxmpeg: Don't drop frames with bad timestamps
Just invalidate the timestamps and let the decoders interpolate.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7121 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/demuxmpeg.c | 53 | ||||
-rw-r--r-- | libhb/internal.h | 2 | ||||
-rw-r--r-- | libhb/reader.c | 4 |
3 files changed, 22 insertions, 37 deletions
diff --git a/libhb/demuxmpeg.c b/libhb/demuxmpeg.c index 32e0d6387..f370caf04 100644 --- a/libhb/demuxmpeg.c +++ b/libhb/demuxmpeg.c @@ -283,6 +283,25 @@ void hb_demux_mpeg(hb_buffer_t *buf, hb_list_t *list_es, if ( buf->s.start >= 0 ) { int64_t fdelta; + if (buf->s.type == AUDIO_BUF || buf->s.type == VIDEO_BUF) + { + if ( state->last_pts >= 0 ) + { + fdelta = buf->s.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->s.start; + state->scr_delta = 0; + } + } + state->last_pts = buf->s.start; + } if (state->last_scr != AV_NOPTS_VALUE) { // Program streams have an SCR in every PACK header so they @@ -299,13 +318,9 @@ void hb_demux_mpeg(hb_buffer_t *buf, hb_list_t *list_es, if ( fdelta < -300 * 90000LL || fdelta > 300 * 90000LL ) { // packet too far behind or ahead of its clock reference - ++state->dts_drops; - ++state->dts_drop_run; - hb_buffer_t *tmp = buf->next; - buf->next = NULL; - hb_buffer_close( &buf ); - buf = tmp; - continue; + buf->s.renderOffset = AV_NOPTS_VALUE; + buf->s.start = AV_NOPTS_VALUE; + buf->s.stop = AV_NOPTS_VALUE; } else { @@ -315,31 +330,7 @@ void hb_demux_mpeg(hb_buffer_t *buf, hb_list_t *list_es, // our scr_delta with each valid timestamp so that // fdelta does not continually grow. state->scr_delta = buf->s.start - state->last_scr; - if (state->dts_drop_run > 0) - { - hb_error("Packet clock reference error. Dropped %d frames.", state->dts_drop_run); - state->dts_drop_run = 0; - } - } - } - if (buf->s.type == AUDIO_BUF || buf->s.type == VIDEO_BUF) - { - if ( state->last_pts >= 0 ) - { - fdelta = buf->s.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->s.start; - state->scr_delta = 0; - } } - state->last_pts = buf->s.start; } } diff --git a/libhb/internal.h b/libhb/internal.h index 442816fa7..85ceb7474 100644 --- a/libhb/internal.h +++ b/libhb/internal.h @@ -285,8 +285,6 @@ typedef struct { int64_t scr_delta; int64_t last_pts; /* last pts we saw */ int scr_changes; /* number of SCR discontinuities */ - int dts_drops; /* number of drops because DTS too far from SCR */ - int dts_drop_run; /* number of consecutive drops */ int new_chap; } hb_psdemux_t; diff --git a/libhb/reader.c b/libhb/reader.c index 073145dda..d5b37c38b 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -770,10 +770,6 @@ void ReadLoop( void * _w ) hb_list_empty( &list ); 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 ); - } } static void UpdateState( hb_work_private_t * r, int64_t start) |