summaryrefslogtreecommitdiffstats
path: root/libhb/sync.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2010-11-06 21:14:14 +0000
committerjstebbins <[email protected]>2010-11-06 21:14:14 +0000
commit45c8e66a3d2c6a8c8e562b52eda70f93abcc6c11 (patch)
tree607dc963c47576e94747479601228290e58c4d84 /libhb/sync.c
parentd573f1a2e6e3a347e1bc9e6ff00d0d3f26605459 (diff)
fix audio sync when resampling 48khz to 44.1khz
Rounding errors in timestamp calculations caused a gradual slip in both sync.c and encfaac.c. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3653 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/sync.c')
-rw-r--r--libhb/sync.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libhb/sync.c b/libhb/sync.c
index 57809d7e2..fac0c3432 100644
--- a/libhb/sync.c
+++ b/libhb/sync.c
@@ -36,7 +36,7 @@ typedef struct
typedef struct
{
int index;
- int64_t next_start; /* start time of next output frame */
+ double next_start; /* start time of next output frame */
int64_t next_pts; /* start time of next input frame */
int64_t first_drop; /* PTS of first 'went backwards' frame dropped */
int drop_count; /* count of 'time went backwards' drops */
@@ -1193,8 +1193,8 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i )
static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf,
hb_sync_audio_t *sync )
{
- int64_t start = sync->next_start;
- int64_t duration = buf->stop - buf->start;
+ int64_t start = (int64_t)sync->next_start;
+ double duration = buf->stop - buf->start;
sync->next_pts += duration;
@@ -1244,13 +1244,13 @@ static hb_buffer_t * OutputAudioFrame( hb_audio_t *audio, hb_buffer_t *buf,
hb_buffer_close( &buf_raw );
buf->size = sync->data.output_frames_gen * channel_count;
- duration = ( sync->data.output_frames_gen * 90000 ) /
+ duration = (double)( sync->data.output_frames_gen * 90000 ) /
audio->config.out.samplerate;
}
buf->frametype = HB_FRAME_AUDIO;
buf->start = start;
- buf->stop = start + duration;
- sync->next_start = start + duration;
+ sync->next_start += duration;
+ buf->stop = (int64_t)sync->next_start;
return buf;
}