From c3ae10e77d76f626c96160e83c58f95377cd98b7 Mon Sep 17 00:00:00 2001 From: arch1t3cht Date: Fri, 5 Apr 2024 00:30:06 +0200 Subject: [PATCH] Store PosInDecodingOrder in index The previous commit updated the index format, so this can now be stored in the index too. --- src/core/track.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/core/track.cpp b/src/core/track.cpp index 6c9f9f2843..1b30951836 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -48,6 +48,7 @@ FrameInfo ReadFrame(ZipFile &stream, FrameInfo const& prev, const FFMS_TrackType f.SampleCount = stream.Read() + prev.SampleCount; } else if (TT == FFMS_TYPE_VIDEO) { f.OriginalPos = static_cast(stream.Read() + prev.OriginalPos + 1); + f.PosInDecodingOrder = static_cast(stream.Read() + prev.PosInDecodingOrder + 1); f.RepeatPict = stream.Read(); f.SecondField = !!stream.Read(); } @@ -65,6 +66,7 @@ static void WriteFrame(ZipFile &stream, FrameInfo const& f, FrameInfo const& pre stream.Write(f.SampleCount - prev.SampleCount); else if (TT == FFMS_TYPE_VIDEO) { stream.Write(static_cast(f.OriginalPos) - prev.OriginalPos - 1); + stream.Write(static_cast(f.PosInDecodingOrder) - prev.PosInDecodingOrder - 1); stream.Write(f.RepeatPict); stream.Write(f.SecondField); } @@ -106,16 +108,8 @@ FFMS_Track::FFMS_Track(ZipFile &stream) for (size_t i = 0; i < FrameCount; ++i) Frames.push_back(ReadFrame(stream, i == 0 ? temp : Frames.back(), TT)); - if (TT == FFMS_TYPE_VIDEO) { + if (TT == FFMS_TYPE_VIDEO) GeneratePublicInfo(); - - // PosInDecodingOrder is currently not stored in the index for backwards compatibility, so - // derive it here (the asserts in FinalizeTrack guarantee that this matches the original values). - // FIXME store OriginalPos in the index the next time the format changes - for (size_t i = 0; i < Frames.size(); i++) { - Frames[Frames[i].OriginalPos].PosInDecodingOrder = i; - } - } } void FFMS_Track::Write(ZipFile &stream) const {