summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
diff options
context:
space:
mode:
authortiter <[email protected]>2006-02-23 14:37:47 +0000
committertiter <[email protected]>2006-02-23 14:37:47 +0000
commitd361af3d7e5f914069e0b5ce49a97b9f97faca95 (patch)
tree16579f538531a32b8384f914ac536e8cbb962f0d /libhb/sync.c
parentdf70394f44cafec40e756803cb9544757add4e17 (diff)
Softer resampling when audio dates are messed up (fix for LPCM issues).
Disabled verbose in the OS X UI git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@30 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/sync.c')
-rw-r--r--libhb/sync.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/libhb/sync.c b/libhb/sync.c
index 32ddb52b7..61e567bbc 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -465,17 +465,18 @@ static void SyncAudio( hb_work_object_t * w, int i )
start = pts_expected - w->pts_offset;
}
- if( ( buf->start + buf->stop ) / 2 < pts_expected )
+ /* Tolerance: 100 ms */
+ if( buf->start < pts_expected - 9000 )
{
/* Late audio, trash it */
+ hb_log( "sync: trashing late audio" );
buf = hb_fifo_get( audio->fifo_raw );
hb_buffer_close( &buf );
continue;
}
-
- if( buf->start > pts_expected + ( buf->stop - buf->start ) / 2 )
+ else if( buf->start > pts_expected + 9000 )
{
- /* Audio push, send a frame of silence */
+ /* Missing audio, send a frame of silence */
InsertSilence( w, i );
continue;
}
@@ -495,24 +496,16 @@ static void SyncAudio( hb_work_object_t * w, int i )
int count_in, count_out;
count_in = buf_raw->size / 2 / sizeof( float );
- count_out = ( buf->stop - pts_expected ) * job->arate / 90000;
+ count_out = ( buf_raw->stop - buf_raw->start ) * job->arate / 90000;
+ if( buf->start < pts_expected - 1500 )
+ count_out--;
+ else if( buf->start > pts_expected + 1500 )
+ count_out++;
sync->data.data_in = (float *) buf_raw->data;
sync->data.input_frames = count_in;
-
- if( buf->start < pts_expected - ( buf->stop - buf->start ) / 5 )
- {
- /* Avoid too heavy downsampling, trash the beginning of
- the buffer instead */
- int drop;
- drop = count_in * ( pts_expected - buf->start ) /
- ( buf->stop - buf->start );
- sync->data.data_in += 2 * drop;
- sync->data.input_frames -= drop;
- hb_log( "dropping %d of %d samples", drop, count_in );
- }
-
sync->data.output_frames = count_out;
+
sync->data.src_ratio = (double) sync->data.output_frames /
(double) sync->data.input_frames;