计算大CRC32的正确方法是什么 [英] What is the correct way of calculating a large CRC32

查看:65
本文介绍了计算大CRC32的正确方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是一篇介绍如何使用现代 x86-64 处理器中的内置 CRC32 指令计算最大 1024 字节的 CRC32.但是,我需要计算超过 1024 个字节的 CRC32.计算每个 1024 字节块的 CRC32 并最终将它们相加是一种正确的方法,还是不正确?如果是这样,正确的做法是什么?

Here is an article that describes how to calculate CRC32 of maximum 1024 bytes using the built in CRC32 instruction found in modern x86-64 processors. However, I need to calculate CRC32 of more than 1024 bytes. Would it be a correct approach to calculate CRC32 of each block of 1024 bytes and in the end sum them, or is it incorrect? If so, what is the correct way to do it?

推荐答案

不,只是添加不能解决问题.

No, just adding won't do the job.

您链接的文章告诉我们如何操作:

The article you linked tells us how to do it:

一次计算的 CRC 输出用作计算的初始 CRC下一个计算 [...]

The CRC output of one calculation is used as the initial CRC for the next calculation [...]

要覆盖最终结果大于 0xffffffff 的情况,只需执行 crc32 = ~crc32 &0xffffffff 最终计算后.

To cover the case of the final result being larger then 0xffffffff just do crc32 = ~crc32 & 0xffffffff after the final calculation.

这篇关于计算大CRC32的正确方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆