]> granicus.if.org Git - handbrake/commitdiff
demuxmpeg: Don't drop frames with bad timestamps
authorjstebbins <jstebbins.hb@gmail.com>
Wed, 22 Apr 2015 21:59:31 +0000 (21:59 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Wed, 22 Apr 2015 21:59:31 +0000 (21:59 +0000)
Just invalidate the timestamps and let the decoders interpolate.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7121 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/demuxmpeg.c
libhb/internal.h
libhb/reader.c

index 32e0d638715e599db7a71fe06d6f785848177913..f370caf0461066c73fe5db92d735a0b3ed1e3f62 100644 (file)
@@ -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;
                 }
             }
 
index 442816fa70bbf08210a1df9767feebeac6927289..85ceb747467d875e92c1a6a5e634d34624452f2f 100644 (file)
@@ -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;
 
index 073145dda3cbab2fa25dad271776cb5af68617ba..d5b37c38b5e5e27c31b56d6d4895d8822f6e8cbb 100644 (file)
@@ -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)