[go: up one dir, main page]

File: RangeDecoder.hpp

package info (click to toggle)
ancient 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,168 kB
  • sloc: cpp: 15,188; makefile: 217; sh: 31
file content (40 lines) | stat: -rw-r--r-- 659 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright (C) Teemu Suutari */

#ifndef RANGEDECODER_HPP
#define RANGEDECODER_HPP

#include <cstdint>

namespace ancient::internal
{

// used by too many compressors...
class RangeDecoder
{
public:
	class BitReader
	{
	public:
		BitReader() noexcept=default;
		virtual ~BitReader() noexcept=default;
		
		virtual uint32_t readBit()=0;
	};

	RangeDecoder(BitReader &bitReader,uint16_t initialValue);
	~RangeDecoder() noexcept=default;

	uint16_t decode(uint16_t length);
	void scale(uint16_t newLow,uint16_t newHigh,uint16_t newRange);

private:
	BitReader			&_bitReader;

	uint16_t			_low{0};
	uint16_t			_high{0xffffU};
	uint16_t			_stream;
};

}

#endif