summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2013-05-15 18:36:40 -0300
committerMichael Niedermayer <michaelni@gmx.at>2013-05-15 23:53:40 +0200
commit35188e91ef941a25be4734d6af58d5903badc476 (patch)
treea89d6b95f07c4021943f9669e12231df8051b950 /libavutil
parentc55c715c81dec16de1c4a55faf0c595e18fff1e5 (diff)
lavu/hash: Fix CRC32 calculation
Initialize it with UINT32_MAX and xor the result with UINT32_MAX as well. Signed-off-by: James Almer <jamrial@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/hash.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libavutil/hash.c b/libavutil/hash.c
index a08d2cf731..03c7ca3f06 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -96,7 +96,7 @@ int av_hash_alloc(AVHashContext **ctx, const char *name)
case SHA160:
case SHA224:
case SHA256: res->ctx = av_sha_alloc(); break;
- case CRC32: res->crctab = av_crc_get_table(AV_CRC_32_IEEE); break;
+ case CRC32: res->crctab = av_crc_get_table(AV_CRC_32_IEEE_LE); break;
case ADLER32: break;
}
if (i != ADLER32 && i != CRC32 && !res->ctx) {
@@ -115,7 +115,7 @@ void av_hash_init(AVHashContext *ctx)
case SHA160: av_sha_init(ctx->ctx, 160); break;
case SHA224: av_sha_init(ctx->ctx, 224); break;
case SHA256: av_sha_init(ctx->ctx, 256); break;
- case CRC32: ctx->crc = 0; break;
+ case CRC32: ctx->crc = UINT32_MAX; break;
case ADLER32: ctx->crc = 1; break;
}
}
@@ -141,7 +141,7 @@ void av_hash_final(AVHashContext *ctx, uint8_t *dst)
case SHA160:
case SHA224:
case SHA256: av_sha_final(ctx->ctx, dst); break;
- case CRC32: AV_WL32(dst, ctx->crc); break;
+ case CRC32: AV_WB32(dst, ctx->crc ^ UINT32_MAX); break;
case ADLER32: AV_WB32(dst, ctx->crc); break;
}
}