Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify CRC32 writing #251

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
19 changes: 3 additions & 16 deletions src/EbmlCrc32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,23 +187,10 @@ bool EbmlCrc32::CheckElementCRC32(EbmlElement &ElementToCRC) const

filepos_t EbmlCrc32::RenderData(IOCallback & output, bool /* bForceRender */, const ShouldWrite & /* writeFilter */)
{
filepos_t Result = 4;
static_assert(sizeof(m_crc_final) == 4, "Bogus CRC internal size");
output.writeFully(&m_crc_final, 4);

if (Result != 0) {
output.writeFully(&m_crc_final, Result);
}

if (Result < GetDefaultSize()) {
// pad the rest with 0
auto Pad = std::make_unique<binary>(GetDefaultSize() - Result);
if (Pad != nullptr) {
output.writeFully(Pad.get(), GetDefaultSize() - Result);

Result = GetDefaultSize();
}
}

return Result;
return 4;
}

filepos_t EbmlCrc32::ReadData(IOCallback & input, ScopeMode ReadFully)
Expand Down