7 static void ec_probmod_samp_and_update(ec_probmod
*_this
,ec_probsamp
*_samp
,
11 _samp
->fs
=ec_bitree_get_freq(_this
->bitree
,_sym
);
12 _samp
->fl
=ec_bitree_get_cumul(_this
->bitree
,_sym
);
14 ec_bitree_update(_this
->bitree
,sz
,_sym
,_this
->inc
);
15 _this
->ft
+=_this
->inc
;
16 if(_this
->ft
>_this
->thresh
){
17 ec_bitree_halve(_this
->bitree
,sz
,_this
->split
);
18 _this
->ft
=ec_bitree_get_cumul(_this
->bitree
,sz
);
22 static void ec_probmod_samp_and_update_range(ec_probmod
*_this
,
23 ec_probsamp
*_samp
,int _sym
,int _lo
,int _hi
){
27 base
=ec_bitree_get_cumul(_this
->bitree
,_lo
);
28 _samp
->fs
=ec_bitree_get_freq(_this
->bitree
,_sym
);
29 _samp
->fl
=ec_bitree_get_cumul(_this
->bitree
,_sym
)-base
;
30 _samp
->ft
=ec_bitree_get_cumul(_this
->bitree
,_hi
)-base
;
31 ec_bitree_update(_this
->bitree
,sz
,_sym
,_this
->inc
);
32 _this
->ft
+=_this
->inc
;
33 if(_this
->ft
>_this
->thresh
){
34 ec_bitree_halve(_this
->bitree
,sz
,_this
->split
);
35 _this
->ft
=ec_bitree_get_cumul(_this
->bitree
,sz
);
39 void ec_probmod_write(ec_probmod
*_this
,ec_enc
*_enc
,int _sym
){
41 ec_probmod_samp_and_update(_this
,&samp
,_sym
);
42 ec_encode(_enc
,samp
.fl
,samp
.fl
+samp
.fs
,samp
.ft
);
45 void ec_probmod_write_range(ec_probmod
*_this
,ec_enc
*_enc
,int _sym
,
48 ec_probmod_samp_and_update_range(_this
,&samp
,_sym
,_lo
,_hi
);
49 ec_encode(_enc
,samp
.fl
,samp
.fl
+samp
.fs
,samp
.ft
);