summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-05-31 17:00:42 +0000
committervan <[email protected]>2008-05-31 17:00:42 +0000
commitafbd06d8d6151b69bbb18adf83cfab8d680c3946 (patch)
tree4e7be731854c8b8db8f87934c301c60a9155387c /libhb/sync.c
parentd0550da569b56a71857c34463c5b030172d47291 (diff)
- support blu-ray, avchd & dvb x264
- support video files handled by ffmpeg (avi, mkv, mp4, etc.) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1480 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/sync.c')
-rw-r--r--libhb/sync.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/libhb/sync.c b/libhb/sync.c
index 34b426f6d..f9c738bdf 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -8,7 +8,7 @@
#include <stdio.h>
#include "samplerate.h"
-#include "ffmpeg/avcodec.h"
+#include "libavcodec/avcodec.h"
#ifdef INT64_MIN
#undef INT64_MIN /* Because it isn't defined correctly in Zeta */
@@ -729,28 +729,34 @@ static void SyncAudio( hb_work_object_t * w, int i )
{
if ( (int64_t)( buf->start - sync->next_pts ) < 0 )
{
- /*
- * audio time went backwards by more than a frame time (this can
- * happen when we reset the PTS because of lost data).
- * Discard data that's in the past.
- */
- if ( sync->first_drop == 0 )
+ // audio time went backwards.
+ // If our output clock is more than a half frame ahead of the
+ // input clock drop this frame to move closer to sync.
+ // Otherwise drop frames until the input clock matches the output clock.
+ if ( sync->first_drop || sync->next_start - buf->start > 90*15 )
{
- sync->first_drop = buf->start;
+ // Discard data that's in the past.
+ if ( sync->first_drop == 0 )
+ {
+ sync->first_drop = sync->next_pts;
+ }
+ ++sync->drop_count;
+ buf = hb_fifo_get( audio->priv.fifo_raw );
+ hb_buffer_close( &buf );
+ continue;
}
- ++sync->drop_count;
- buf = hb_fifo_get( audio->priv.fifo_raw );
- hb_buffer_close( &buf );
- continue;
+ sync->next_pts = buf->start;
}
if ( sync->first_drop )
{
+ // we were dropping old data but input buf time is now current
hb_log( "sync: audio %d time went backwards %d ms, dropped %d frames "
"(next %lld, current %lld)", i,
(int)( sync->next_pts - sync->first_drop ) / 90,
sync->drop_count, sync->first_drop, sync->next_pts );
sync->first_drop = 0;
sync->drop_count = 0;
+ sync->next_pts = buf->start;
}
if ( buf->start - sync->next_pts >= (90 * 70) )
{