summaryrefslogtreecommitdiff
path: root/vcl/source/bitmap/checksum.cxx
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2015-08-26 13:50:57 +0200
committerMichael Meeks <michael.meeks@collabora.com>2015-09-01 16:28:45 +0100
commitebb0dc14547e698d7b53005178063da72d48f075 (patch)
tree8cf95d717f32672dc8e6ecf9f6b743227ada889f /vcl/source/bitmap/checksum.cxx
parent7cc4cdc5ef6dff279e072af725c2d7fc1e5da0e8 (diff)
Added support for computing 64-bit checksum of bitmap in OpenGL
Added a C++ and a GLSL implementation of a 64-bit CRC algorithm. Changed hardcoded checksum value in ooxmlimport unit test (testN777345). Change-Id: I16bb985a14866775efda49e21fe033ff64645896
Diffstat (limited to 'vcl/source/bitmap/checksum.cxx')
-rw-r--r--vcl/source/bitmap/checksum.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/vcl/source/bitmap/checksum.cxx b/vcl/source/bitmap/checksum.cxx
new file mode 100644
index 000000000000..a46db1e75265
--- /dev/null
+++ b/vcl/source/bitmap/checksum.cxx
@@ -0,0 +1,51 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sal/types.h>
+#include <checksum.hxx>
+
+/*========================================================================
+ *
+ * vcl_crc64 implementation.
+ *
+ *======================================================================*/
+#define UPDCRC64(crc, octet) \
+ (vcl_crc64Table[((crc) ^ (octet)) & 0xff] ^ ((crc) >> 8))
+
+/*
+ * rtl_crc64.
+ */
+sal_uInt64 SAL_CALL vcl_crc64 (
+ sal_uInt64 Crc,
+ const void *Data, sal_uInt32 DatLen) SAL_THROW_EXTERN_C()
+{
+ if (Data)
+ {
+ const sal_uInt8 *p = static_cast<const sal_uInt8 *>(Data);
+ const sal_uInt8 *q = p + DatLen;
+
+ Crc = ~Crc;
+ while (p < q)
+ Crc = UPDCRC64(Crc, *(p++));
+ Crc = ~Crc;
+ }
+ return Crc;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */