diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-08-31 16:03:17 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-31 20:21:44 +0000 |
commit | 2a1c8ac53f249bfe2789ea95170f11d308992449 (patch) | |
tree | be3fae81a04ac8fdfc851bf2f9f25cf60967835d /core/fxcrt/fx_basic_util.cpp | |
parent | 203188ac4275f83cf984b8a807b07b74ab139236 (diff) | |
download | pdfium-2a1c8ac53f249bfe2789ea95170f11d308992449.tar.xz |
Move fx_extension implementation to cpp file
This CL moves the GetBits32 implemenation into fx_extension.cpp. It
also moves some of the fx_basic unittests to the correct unittest files.
Change-Id: I2cf8657c228375508db0f02baa628d62a3b2ab25
Reviewed-on: https://pdfium-review.googlesource.com/12673
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_basic_util.cpp')
-rw-r--r-- | core/fxcrt/fx_basic_util.cpp | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp deleted file mode 100644 index 704fd18418..0000000000 --- a/core/fxcrt/fx_basic_util.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include <algorithm> - -#include "core/fxcrt/fx_system.h" - -uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits) { - ASSERT(0 < nbits && nbits <= 32); - const uint8_t* dataPtr = &pData[bitpos / 8]; - int bitShift; - int bitMask; - int dstShift; - int bitCount = bitpos & 0x07; - if (nbits < 8 && nbits + bitCount <= 8) { - bitShift = 8 - nbits - bitCount; - bitMask = (1 << nbits) - 1; - dstShift = 0; - } else { - bitShift = 0; - int bitOffset = 8 - bitCount; - bitMask = (1 << std::min(bitOffset, nbits)) - 1; - dstShift = nbits - bitOffset; - } - uint32_t result = - static_cast<uint32_t>((*dataPtr++ >> bitShift & bitMask) << dstShift); - while (dstShift >= 8) { - dstShift -= 8; - result |= *dataPtr++ << dstShift; - } - if (dstShift > 0) { - bitShift = 8 - dstShift; - bitMask = (1 << dstShift) - 1; - result |= *dataPtr++ >> bitShift & bitMask; - } - return result; -} |