ГОСТ Р 53556.4—2013
5.2.6.27.3Программное обеспечение
unsigned tong half]16] =
{
0x20000000.0x10000000.0x08000000. 0x04000000.
0x02000000.0x01000000.0x00800000.0x00400000.
0x00200000.0x00100000.0x00080000.0x00040000.
0x00020000.0x00010000.0x00008000. 0x00004000
Я
Г Initialize the Paramoteres of the Arithmetic Decoder V
voidinitArDecodef)
{
value = 0:
r
range = 1:
est_cwjen = 30:
;
’
GENEARL ARITHMETIC DECODE 7
int decode_symbol (bufjdx, cumjreq. symbol)
int bufjdx.
int cum_freq[]:
/* bufforindex to save the arithmetic code v/ord V
Г Cumulative symbol freqenctos У
int *symbol;Г Symbol decoded У
{
if(est_cwjen) {
range =(range « est_cw_len):
value = (value « est_cwjen) \readBits(buf_idx. est_cw_len):
/* read bitstream from the buffer У
}
range » = 14:
cum = valuo/range:/* Find cum freq У
/* Find symbol У
for (sym = 0. cum_freq[sym]>cum; sym++);
*symbol = sym;
/* Narrow the code region to that allotted to this symbol. У
value -= (range ’ cumjreqfsym));
if (sym > 0) {
range = range * (cumjreqfsym-1]-cumJreq[sym]):
}
else {
range = range * (16384-cumjreq(sym]);
}
for (est_cwjen = 0. range <half(est_cwJen]: est_c\vjen++) ;
returnest cw len;
}
Г BINARY ARITHMETIC-DECODE THE NEXT SYMBOL. V
int decode_symbof2 (bufjdx. frcqO. symbol)
int bufjdx: /* buffer index to save the arithmetic code word У
int pO:Г Normalized probability of symbol 0 У
int *symbol; Г Symbol decoded У
{
if(est_cwjen) {
range =(range « est_cw_len):
value = (value « est_cwjen) \ readBits(buf_idx. est_cw_len):
Г read bitstream from the buffer У
}
range » = 14:
88