RiceDeltaDecoder.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef RICE_DELTA_DECODER_H
  5. #define RICE_DELTA_DECODER_H
  6. namespace mozilla {
  7. namespace safebrowsing {
  8. class RiceDeltaDecoder {
  9. public:
  10. // This decoder is tailored for safebrowsing v4, including the
  11. // bit reading order and how the remainder part is interpreted.
  12. // The caller just needs to feed the byte stream received from
  13. // network directly. Note that the input buffer must be mutable
  14. // since the decoder will do some pre-processing before decoding.
  15. RiceDeltaDecoder(uint8_t* aEncodedData, size_t aEncodedDataSize);
  16. // @param aNumEntries The number of values to be decoded, not including
  17. // the first value.
  18. // @param aDecodedData A pre-allocated output buffer. Note that
  19. // aDecodedData[0] will be filled with |aFirstValue|
  20. // and the buffer length (in byte) should be
  21. // ((aNumEntries + 1) * sizeof(uint32_t)).
  22. bool Decode(uint32_t aRiceParameter,
  23. uint32_t aFirstValue,
  24. uint32_t aNumEntries,
  25. uint32_t* aDecodedData);
  26. private:
  27. uint8_t* mEncodedData;
  28. size_t mEncodedDataSize;
  29. };
  30. } // namespace safebrowsing
  31. } // namespace mozilla
  32. #endif // UPDATE_V4_DECODER_H