From 26c01e7ec65999629c372efc8ab3af9fd03fb09f Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Mon, 11 May 2009 09:52:48 -0700 Subject: [PATCH] apply timescale to BlockDuration --- src/matroska.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/matroska.c b/src/matroska.c index 94adf63..e399571 100644 --- a/src/matroska.c +++ b/src/matroska.c @@ -194,11 +194,13 @@ int mk_flushFrame(mk_Writer *w, mk_Track *track) int i; char *laced = NULL; uint64_t length = 0; + uint64_t block_duration = 0; if (!track->in_frame) return 0; delta = track->frame.timecode / w->timescale - w->cluster.tc_scaled; + block_duration = track->frame.duration / w->timescale; /* If switch rapidly back-and-forth between tracks with drastically different timecodes * this causes a new cluster to be written each time a switch is made. This causes * unnecessary overhead. @@ -263,9 +265,9 @@ int mk_flushFrame(mk_Writer *w, mk_Track *track) ref = track->prev_frame_tc_scaled - w->cluster.tc_scaled - delta; bgsize += 1 + 1 + mk_ebmlSIntSize(ref); } - if (track->frame.duration > 0) /* BlockDuration */ + if (block_duration > 0) /* BlockDuration */ { - bgsize += 1 + 1 + mk_ebmlUIntSize(track->frame.duration); + bgsize += 1 + 1 + mk_ebmlUIntSize(block_duration); } CHECK(mk_writeID(w->cluster.context, MATROSKA_ID_BLOCKGROUP)); /* BlockGroup */ @@ -309,8 +311,8 @@ int mk_flushFrame(mk_Writer *w, mk_Track *track) if (!track->frame.keyframe) /* ReferenceBlock */ CHECK(mk_writeSInt(w->cluster.context, MATROSKA_ID_REFERENCEBLOCK, ref)); - if (track->frame.duration > 0) /* BlockDuration */ - CHECK(mk_writeUInt(w->cluster.context, 0x9b, track->frame.duration)); + if (block_duration > 0) /* BlockDuration */ + CHECK(mk_writeUInt(w->cluster.context, 0x9b, block_duration)); /* This may get a little out of hand, but it seems sane enough for now. */ if (track->frame.keyframe && (track->track_type == MK_TRACK_VIDEO)) { -- 2.11.4.GIT