Skip to content

Commit

Permalink
Add pseudocode examples for Range Binary Values
Browse files Browse the repository at this point in the history
Addresses #230 and #231.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Github: Closes #242
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
  • Loading branch information
dwbuiten authored and michaelni committed Oct 5, 2020
1 parent 5efbbae commit 7f83e08
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions ffv1.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,52 @@ SVGI:!---
SVGC:rangebinaryvalues7.svg=$$j_{0}=2$$
AART:j_(0) = 2
```c
range = 0xFF00;
end = 0;
low = get_bits(16);
if (low >= range) {
low = range;
end = 1;
}
```
Figure: A pseudo-code description of the initial states in Range Binary mode.

```c
refill() {
if (range < 256) {
range = range * 256;
low = low * 256;
if (!end) {
c.low += get_bits(8);
if (remaining_bits_in_bitstream( NumBytes ) == 0) {
end = 1;
}
}
}
}
```
Figure: A pseudo-code description of refilling the Range Binary Value coder buffer.

```c
get_rac(state) {
rangeoff = (range * state) / 256;
range -= rangeoff;
if (low < range) {
state = zero_state[state];
refill();
return 0;
} else {
low -= range;
state = one_state[state];
range = rangeoff;
refill();
return 1;
}
}
```
Figure: A pseudo-code description of the read of a binary value in Range Binary mode.
##### Termination
The range coder can be used in three modes.
Expand Down

0 comments on commit 7f83e08

Please sign in to comment.