Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/demuxer/iso/ErrorRecovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,18 @@ bool ErrorRecovery::RepairSampleToChunkTable(SampleTableInfo& tables) {
}

// Check for invalid entries in sample-to-chunk table
for (auto it = tables.sampleToChunkEntries.begin(); it != tables.sampleToChunkEntries.end(); ) {
if (it->samplesPerChunk == 0 || it->sampleDescIndex == 0) {
// Invalid entry, remove it
it = tables.sampleToChunkEntries.erase(it);
LogError("ChunkTableRepair", "Removed invalid sample-to-chunk entry");
} else {
++it;
}
size_t originalSize = tables.sampleToChunkEntries.size();
tables.sampleToChunkEntries.erase(
std::remove_if(tables.sampleToChunkEntries.begin(), tables.sampleToChunkEntries.end(),
[](const auto& entry) {
return entry.samplesPerChunk == 0 || entry.sampleDescIndex == 0;
}),
tables.sampleToChunkEntries.end()
);

size_t removedCount = originalSize - tables.sampleToChunkEntries.size();
for (size_t i = 0; i < removedCount; ++i) {
LogError("ChunkTableRepair", "Removed invalid sample-to-chunk entry");
}
Comment on lines +212 to 214
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this loop accurately duplicates the original logging behavior as noted in the PR description, calling LogError $N$ times introduces a significant $O(N)$ overhead due to the std::map lookup and string handling inside LogError. For large datasets (e.g., the $N=50,000$ case mentioned in the benchmarks), this overhead will likely dominate the execution time, negating much of the performance gain achieved by the std::remove_if optimization. Unless individual log entries are strictly required for each removed item, consider logging a single summary message and updating the statistics in bulk.

    if (removedCount > 0) {
        LogError("ChunkTableRepair", "Removed " + std::to_string(removedCount) + " invalid sample-to-chunk entries");
        if (removedCount > 1) {
            errorStats["ChunkTableRepair"] += static_cast<int>(removedCount - 1);
        }
    }


// If all entries were invalid, create a default entry
Expand Down
Empty file modified util/build-deps.sh
100644 → 100755
Empty file.
Loading