# Need help to develop the matlab code

#### tojeena

Joined May 2, 2009
118
his is used in decoding part of subexponential codes used for image compression.n is binary which is i/p binary stream,k be a parameter.There are two conditions for decoding n<2^k and n>=2^k.

First case is n=010011,k=3 i need to decode with k bits ie.3 bits. The theory is If the first bit is 0, the following k bits are the decoded value.

Second case is n=110011,first bit is 1,i need to split the msb part upto the stopbit 0.This is the unary part(110) and also want to separate 011 as binary part(another part).

My problem is to implement the first case and second case in matlab.I am copy pasting the C code of the decoding portion of subexponential coding.

Rich (BB code):
if true
% uintmax_t result =0;
// Subexponential has two different cases
if (( membuff -> GetBit ())==0){
// Case n <(2^ k)
return ( int ) membuff -> Get (k );
} else {
// Case n >(2^ k)
int b ,u;
uintmax_t base ;
// Count the number of 1' s until the stop bit .
while ( membuff - > GetBit ()){
u ++;
}
// Now the least b significant bits have to be read .
b=u +k -1;
base =1 < < b;
result = ( base | membuff - > Get (b ));
return ( int ) result ;
}
end
Thank you so much for helping me.

Last edited by a moderator: