diff options
author | van <[email protected]> | 2008-11-08 06:26:57 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-11-08 06:26:57 +0000 |
commit | 89eef8d080649cc44a1abc7ed0a0248c6976951d (patch) | |
tree | 1d188bb7a927972bdf96ab24dc9544ffb180ed54 | |
parent | 9f6d2aa0349191b7f83e9db200f0de16bf868670 (diff) |
- Always use HandBrake's DTS decoder rather than ffmpeg's even for inputs we read via ffmpeg so that we get the user-specified mixdown. Otherwise we eventually abort in the sample rate converter or audio encoder.
- Teach HB's DTS coder to handle implicit timestamps so that it doesn't screw up on mkv's & some m2ts inputs.
- mkv's produced from Bluray HD content seem to have large timestamp errors - filter them out in the decoder so that sync doesn't drop big chunks of our audio.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1904 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/decdca.c | 25 | ||||
-rwxr-xr-x | libhb/stream.c | 4 |
2 files changed, 23 insertions, 6 deletions
diff --git a/libhb/decdca.c b/libhb/decdca.c index 0c905af10..b58a9ef79 100644 --- a/libhb/decdca.c +++ b/libhb/decdca.c @@ -14,6 +14,7 @@ struct hb_work_private_s /* libdca handle */ dca_state_t * state; + double next_pts; int flags_in; int flags_out; int rate; @@ -145,7 +146,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w ) hb_work_private_t * pv = w->private_data; hb_buffer_t * buf; int i, j, k; - uint64_t pts, pos; + int64_t pts, pos; int num_blocks; /* Get a frame header if don't have one yet */ @@ -181,8 +182,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w ) } } - if( !pv->sync || - hb_list_bytes( pv->list ) < pv->size ) + if( !pv->sync || hb_list_bytes( pv->list ) < pv->size ) { /* Need more data */ return NULL; @@ -198,9 +198,22 @@ static hb_buffer_t * Decode( hb_work_object_t * w ) num_blocks = dca_blocks_num( pv->state ); /* num_blocks blocks per frame, 256 samples per block, channelsused channels */ - buf = hb_buffer_init( num_blocks * 256 * pv->out_discrete_channels * sizeof( float ) ); - buf->start = pts + ( pos / pv->size ) * num_blocks * 256 * 90000 / pv->rate; - buf->stop = buf->start + num_blocks * 256 * 90000 / pv->rate; + int nsamp = num_blocks * 256; + buf = hb_buffer_init( nsamp * pv->out_discrete_channels * sizeof( float ) ); + + // mkv files typically use a 1ms timebase which results in a lot of + // truncation error in their timestamps. Also, TSMuxer or something + // in the m2ts-to-mkv toolchain seems to take a very casual attitude + // about time - timestamps seem to randomly offset by ~40ms for a few + // seconds then recover. So, if the pts we got is within 50ms of the + // pts computed from the data stream, use the data stream pts. + if ( pts < 0 || fabs( (double)pts - pv->next_pts ) < 50.*90. ) + { + pts = pv->next_pts; + } + buf->start = pts; + pv->next_pts += (double)nsamp / (double)pv->rate * 90000.; + buf->stop = pv->next_pts; for( i = 0; i < num_blocks; i++ ) { diff --git a/libhb/stream.c b/libhb/stream.c index 665cea6f3..ee5c5f634 100755 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -2520,6 +2520,10 @@ static void add_ffmpeg_audio( hb_title_t *title, hb_stream_t *stream, int id ) { audio->config.in.codec = HB_ACODEC_AC3; } + else if ( codec->codec_id == CODEC_ID_DTS ) + { + audio->config.in.codec = HB_ACODEC_DCA; + } else { audio->config.in.codec = HB_ACODEC_FFMPEG; |