From 7a170eb98c6102c14fea83626b651c2481b05cc8 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 7 Aug 2005 10:01:35 +0000 Subject: [PATCH] Always recalculate the maximum number of ns per cluster, not only for sample precision mode. Otherwise low values for --timecode-scale would cause libmatroska to assert(). --- src/merge/output_control.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/merge/output_control.cpp b/src/merge/output_control.cpp index 7495754a7..b1f2a48f3 100644 --- a/src/merge/output_control.cpp +++ b/src/merge/output_control.cpp @@ -444,7 +444,7 @@ static void set_timecode_scale() { vector::const_iterator ptzr; bool video_present, audio_present; - int64_t highest_sample_rate; + int64_t highest_sample_rate, max_ns_with_timecode_scale; video_present = false; audio_present = false; @@ -465,23 +465,15 @@ set_timecode_scale() { if (timecode_scale_mode != TIMECODE_SCALE_MODE_FIXED) { if (audio_present && (highest_sample_rate > 0) && (!video_present || - (timecode_scale_mode == TIMECODE_SCALE_MODE_AUTO))) { - int64_t max_ns_with_timecode_scale; - + (timecode_scale_mode == TIMECODE_SCALE_MODE_AUTO))) timecode_scale = (double)1000000000.0 / (double)highest_sample_rate - 1.0; - max_ns_with_timecode_scale = (int64_t)(32700 * timecode_scale); - if (max_ns_with_timecode_scale < max_ns_per_cluster) - max_ns_per_cluster = max_ns_with_timecode_scale; - - mxverb(2, "mkvmerge: using sample precision timestamps. highest sample " - "rate: %lld, new timecode_scale: %f, " - "max_ns_with_timecode_scale: %lld, max_ns_per_cluster: %lld\n", - highest_sample_rate, timecode_scale, max_ns_with_timecode_scale, - max_ns_per_cluster); - } } + max_ns_with_timecode_scale = (int64_t)(32700 * timecode_scale); + if (max_ns_with_timecode_scale < max_ns_per_cluster) + max_ns_per_cluster = max_ns_with_timecode_scale; + KaxTimecodeScale &time_scale = GetChild(*kax_infos); *(static_cast(&time_scale)) = (int64_t)timecode_scale;