Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: third_party/zlib/crc32.c

Issue 552123005: Integrate SIMD optimisations for zlib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crc_fold_copy to work with inputs where len % 16 > 0 Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/zlib/crc32.c
diff --git a/third_party/zlib/crc32.c b/third_party/zlib/crc32.c
index 91be372d224da6833c03bd24d7158ff622ece35f..75f2290d83c23978afb645fe677871a8f4ba88db 100644
--- a/third_party/zlib/crc32.c
+++ b/third_party/zlib/crc32.c
@@ -26,6 +26,8 @@
# endif /* !DYNAMIC_CRC_TABLE */
#endif /* MAKECRCH */
+#include "deflate.h"
+#include "x86.h"
#include "zutil.h" /* for STDC and FAR definitions */
#define local static
@@ -440,3 +442,28 @@ uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
{
return crc32_combine_(crc1, crc2, len2);
}
+
+ZLIB_INTERNAL void crc_reset(deflate_state *const s)
+{
+ if (x86_cpu_enable_simd) {
+ crc_fold_init(s);
+ return;
+ }
+ s->strm->adler = crc32(0L, Z_NULL, 0);
+}
+
+ZLIB_INTERNAL void crc_finalize(deflate_state *const s)
+{
+ if (x86_cpu_enable_simd)
+ s->strm->adler = crc_fold_512to32(s);
+}
+
+ZLIB_INTERNAL void copy_with_crc(z_streamp strm, Bytef *dst, long size)
+{
+ if (x86_cpu_enable_simd) {
+ crc_fold_copy(strm->state, dst, strm->next_in, size);
+ return;
+ }
+ zmemcpy(dst, strm->next_in, size);
+ strm->adler = crc32(strm->adler, dst, size);
+}

Powered by Google App Engine
This is Rietveld 408576698