Commit 4a1c26f8 for libheif

commit 4a1c26f83e146abf7912e137694a73cdb2702b50
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Fri Dec 19 10:26:19 2025 +0100

    [BSD3] add ctts box only if there is frame-reordering

diff --git a/libheif/sequences/track.cc b/libheif/sequences/track.cc
index 3d2b52d2..7ffa3dae 100644
--- a/libheif/sequences/track.cc
+++ b/libheif/sequences/track.cc
@@ -481,8 +481,7 @@ Track::Track(HeifContext* ctx, uint32_t track_id, const TrackOptions* options, u
   m_stbl->append_child_box(m_stts);

   m_ctts = std::make_shared<Box_ctts>();
-  m_stbl->append_child_box(m_ctts);
-  // TODO: will only be added when needed
+  // The ctts box will be added in finalize_track(), but only there is frame-reordering.

   m_stsc = std::make_shared<Box_stsc>();
   m_stbl->append_child_box(m_stsc);
@@ -719,6 +718,11 @@ Error Track::finalize_track()

   m_stss->set_total_number_of_samples(m_stsz->num_samples());

+  // only add ctts box if we use frame-reordering
+  if (!m_ctts->is_constant_offset()) {
+    m_stbl->append_child_box(m_ctts);
+  }
+
   return {};
 }