summaryrefslogtreecommitdiffstats
path: root/libhb/muxmp4.c
diff options
context:
space:
mode:
authorvan <[email protected]>2008-04-25 06:44:35 +0000
committervan <[email protected]>2008-04-25 06:44:35 +0000
commita9bfe5ac17c00f334b813e78a4fb9394ad8dd148 (patch)
treed576667ab49aec5c59d4ce87cfe456d4faf07d39 /libhb/muxmp4.c
parent036bf17b1af2c696ff25b8af728a25b042e190be (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/muxmp4.c')
-rw-r--r--libhb/muxmp4.c23
1 files changed, 21 insertions, 2 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,