diff --git a/Main/src/Image.h b/Main/src/Image.h index a0370f16..b56ac9cf 100644 --- a/Main/src/Image.h +++ b/Main/src/Image.h @@ -412,7 +412,7 @@ void RemoveConsecutiveBeforeEnd(TLogTime tEndMax); }; protected: - const PLogTime logTimes; // absolute logical times since the start of recording + PLogTime logTimes; // absolute logical times since the start of recording const TDecoderMethod method; bool resetDecoderOnIndex; DWORD iNextTime,nLogTimes; diff --git a/Main/src/Image_TrackRW.cpp b/Main/src/Image_TrackRW.cpp index 2ddb7a74..32881529 100644 --- a/Main/src/Image_TrackRW.cpp +++ b/Main/src/Image_TrackRW.cpp @@ -1525,10 +1525,11 @@ // - ignoring what's before the first Index TLogTime tCurrIndexOrg=RewindToIndex(0); // - normalization - const TLogTime tLastIndex=GetIndexTime(nIndexPulses-1); + const TLogTime tLastIndex=GetLastIndexTime(); const DWORD iModifStart=iNextTime; DWORD iTime=iModifStart; - const Utils::CCallocPtr buffer(GetBufferCapacity()); + const DWORD nLogTimesMaxNew=std::max( nIndexPulses*mp->nCells, GetBufferCapacity() ); + const Utils::CCallocPtr buffer( nLogTimesMaxNew, 0 ); // pessimistic estimation for FM encoding const PLogTime ptModified=buffer.get(); for( BYTE nextIndex=1; nextIndex=GetBufferCapacity()) - return ERROR_INSUFFICIENT_BUFFER; // mustn't overrun the Buffer - ::memmove( logTimes+iTime, logTimes+iNextTime, (nLogTimes-iNextTime)*sizeof(TLogTime) ); - nLogTimes+=iTime-iNextTime; - if (const TLogTime dt=indexPulses[nIndexPulses-1]-tLastIndex) - for( DWORD i=iTime; i