image thumbnail
from Yet another arithmetic coding example by Samuel Cheng
A simple arithmetic coder that I used it in class.

arith_code
classdef arith_code
    properties (Constant)
        num_bit_precision=6;
    end
    properties 
        debug=1;
        top_value
        max_freq
        half
        onefourth
        threefourth
        fontsize
    end    
    methods
        function o=arith_code()
            o=set_constants(o);
        end
    end
end

function obj=set_constants(obj)

obj.top_value=pow2(obj.num_bit_precision)-1;
obj.max_freq=pow2(obj.num_bit_precision-2)-1;
obj.half=ceil(obj.top_value/2);
obj.onefourth=ceil(obj.top_value/4);
obj.threefourth=obj.onefourth*3;

end

Contact us