diff options
author | van <[email protected]> | 2008-04-25 06:44:35 +0000 |
---|---|---|
committer | van <[email protected]> | 2008-04-25 06:44:35 +0000 |
commit | a9bfe5ac17c00f334b813e78a4fb9394ad8dd148 (patch) | |
tree | d576667ab49aec5c59d4ce87cfe456d4faf07d39 /libhb | |
parent | 036bf17b1af2c696ff25b8af728a25b042e190be (diff) |
- Don't allow chapter durations to go negative (since durations are unsigned the result will be interpreted as a huge positive number).
- Revert the change to sync that pushed out the final frame of video -- on many DVDs this frame seems to be junk that's not intended to be displayed.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1438 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/muxmp4.c | 23 | ||||
-rw-r--r-- | libhb/sync.c | 24 |
2 files changed, 31 insertions, 16 deletions
diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index c401c968f..b20b9a466 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -388,6 +388,15 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data, { duration += buf->renderOffset * m->samplerate / 90000; } + if ( duration <= 0 ) + { + /* The initial & final chapters can have very short durations + * (less than the error in our total duration estimate) so + * the duration calc above can result in a negative number. + * when this happens give the chapter a short duration (1/3 + * of an ntsc frame time). */ + duration = 1000 * m->samplerate / 90000; + } sample = MP4GenerateChapterSample( m, duration, buf->new_chap ); @@ -467,8 +476,18 @@ static int MP4End( hb_mux_object_t * m ) /* Write our final chapter marker */ if( m->job->chapter_markers ) { - struct hb_text_sample_s *sample = MP4GenerateChapterSample( m, - (m->sum_dur - m->chapter_duration), + int64_t duration = m->sum_dur - m->chapter_duration; + if ( duration <= 0 ) + { + /* The initial & final chapters can have very short durations + * (less than the error in our total duration estimate) so + * the duration calc above can result in a negative number. + * when this happens give the chapter a short duration (1/3 + * of an ntsc frame time). */ + duration = 1000 * m->samplerate / 90000; + } + + struct hb_text_sample_s *sample = MP4GenerateChapterSample( m, duration, m->current_chapter + 1 ); if( !MP4WriteSample(m->file, diff --git a/libhb/sync.c b/libhb/sync.c index 90e7fc345..d78398531 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -289,10 +289,9 @@ static int SyncVideo( hb_work_object_t * w ) return HB_WORK_OK; } cur = pv->cur; - if( cur->size == 0 && pv->pts_offset == INT64_MIN ) + if( cur->size == 0 ) { - /* we got an end-of-stream with no video frames (happens during - * an indepth_scan). Feed the eos downstream & signal that we're done. */ + /* we got an end-of-stream. Feed it downstream & signal that we're done. */ hb_fifo_push( job->fifo_sync, hb_buffer_init( 0 ) ); pv->done = 1; return HB_WORK_DONE; @@ -309,13 +308,14 @@ static int SyncVideo( hb_work_object_t * w ) if( next->size == 0 ) { - // we got the empty buffer that signals end-of-stream - // note that we're done but continue to the end of this - // loop so that the final frame gets processed. + /* we got an end-of-stream. Feed it downstream & signal that + * we're done. Note that this means we drop the final frame of + * video (we don't know its duration). On DVDs the final frame + * is often strange and dropping it seems to be a good idea. */ + hb_fifo_push( job->fifo_sync, hb_buffer_init( 0 ) ); pv->done = 1; - next->start = pv->next_pts + 90*30; + return HB_WORK_DONE; } - if( pv->pts_offset == INT64_MIN ) { /* This is our first frame */ @@ -625,13 +625,9 @@ static int SyncVideo( hb_work_object_t * w ) /* Make sure we won't get more frames then expected */ if( pv->count_frames >= pv->count_frames_max * 2) { - hb_log( "sync: got too many frames (%d), exiting early", pv->count_frames ); + hb_log( "sync: got too many frames (%d), exiting early", + pv->count_frames ); pv->done = 1; - } - - if ( pv->done ) - { - hb_buffer_close( &pv->cur ); // Drop an empty buffer into our output to ensure that things // get flushed all the way out. |