Skip to content

Commit

Permalink
Merge pull request #370 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Added detection and reporting of range issues.
  • Loading branch information
forkineye authored Sep 30, 2021
2 parents b3be31a + 4fac621 commit 019e25c
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions ESPixelStick/src/input/InputFPPRemotePlayFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ bool c_InputFPPRemotePlayFile::ParseFseqFile ()
fsqParsedHeader.numCompressedBlocks * 8 + sizeof (FseqRawRanges));

uint32_t SparseRangeIndex = 0;
uint32_t TotalChannels = 0;
uint32_t LargestOffset = 0;
uint32_t LargestBlock = 0;
for (auto & CurrentSparseRange : SparseRanges)
{
// DEBUG_V (String (" Sparse Range Index: ") + String (SparseRangeIndex));
Expand All @@ -280,16 +283,46 @@ bool c_InputFPPRemotePlayFile::ParseFseqFile ()

CurrentSparseRange.DataOffset = read24 (FseqRawRanges[SparseRangeIndex].Start);
CurrentSparseRange.ChannelCount = read24 (FseqRawRanges[SparseRangeIndex].Length);
TotalChannels += CurrentSparseRange.ChannelCount;
LargestOffset = max (LargestOffset, CurrentSparseRange.DataOffset);
LargestBlock = max (LargestBlock, CurrentSparseRange.DataOffset + CurrentSparseRange.ChannelCount);

// DEBUG_V (String (" RangeChannelCount: ") + String (CurrentSparseRange.ChannelCount));
// DEBUG_V (String (" RangeChannelCount: ") + String (CurrentSparseRange.ChannelCount));
// DEBUG_V (String (" RangeDataOffset: 0x") + String (CurrentSparseRange.DataOffset, HEX));

++SparseRangeIndex;
}

// DEBUG_V (String (" TotalChannels: ") + String (TotalChannels));
// DEBUG_V (String (" LargestOffset: ") + String (LargestOffset));
// DEBUG_V (String (" LargestBlock: ") + String (LargestBlock));
if (TotalChannels > fsqParsedHeader.channelCount)
{
LastFailedPlayStatusMsg = (String (F ("ParseFseqFile:: Ignoring Range Info. ")) + PlayItemName + F (" Too many channels defined in Sparse Ranges."));
logcon (LastFailedPlayStatusMsg);
memset ((void*)&SparseRanges, 0x00, sizeof (SparseRanges));
SparseRanges[0].ChannelCount = fsqParsedHeader.channelCount;
}

else if (LargestOffset > fsqParsedHeader.channelCount)
{
LastFailedPlayStatusMsg = (String (F ("ParseFseqFile:: Ignoring Range Info. ")) + PlayItemName + F (" Sparse Range Frame offset is larger than frame size."));
logcon (LastFailedPlayStatusMsg);
memset ((void*)&SparseRanges, 0x00, sizeof (SparseRanges));
SparseRanges[0].ChannelCount = fsqParsedHeader.channelCount;
}

else if (LargestBlock > fsqParsedHeader.channelCount)
{
LastFailedPlayStatusMsg = (String (F ("ParseFseqFile:: Ignoring Range Info. ")) + PlayItemName + F (" Sparse Range Frame offset + Num channels is larger than frame size."));
logcon (LastFailedPlayStatusMsg);
memset ((void*)&SparseRanges, 0x00, sizeof (SparseRanges));
SparseRanges[0].ChannelCount = fsqParsedHeader.channelCount;
}
}
else
{
SparseRanges[0].DataOffset = 0;
memset ((void*)&SparseRanges, 0x00, sizeof (SparseRanges));
SparseRanges[0].ChannelCount = fsqParsedHeader.channelCount;
}

Expand Down

0 comments on commit 019e25c

Please sign in to comment.