# Need help to develop the matlab code

Discussion in 'Programmer's Corner' started by tojeena, Aug 10, 2013.

1. ### tojeena Thread Starter Active Member

May 2, 2009
118
0
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.

Code ( (Unknown Language)):
1.
2. if true
3.   % uintmax_t result =0;
4. // Subexponential has two different cases
5. if (( membuff -> GetBit ())==0){
6. // Case n <(2^ k)
7. return ( int ) membuff -> Get (k );
8. } else {
9. // Case n >(2^ k)
10. int b ,u;
11. uintmax_t base ;
12. // Count the number of 1' s until the stop bit .
14. while ( membuff - > GetBit ()){
15. u ++;
16. }
17. // Now the least b significant bits have to be read .
18. b=u +k -1;
19. base =1 < < b;
20. result = ( base | membuff - > Get (b ));
21. return ( int ) result ;
22. }
23. end
24.
Thank you so much for helping me.

Last edited by a moderator: Aug 10, 2013