Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

huffman encoder and decoder block diagram

Status
Not open for further replies.

saur

Member level 2
Joined
Feb 23, 2012
Messages
45
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,621
I know the huffman coding and decoding scheme.....
but am not able to understand how it can be implemented in real world....
has anyone got some idea as to how it is implemented?
 

Code:
#include<conio.h>
#include<iostream,h>
#include<string.h>
#include <stdio.h>
#include <stdlib.h>
int codes[512];
char cut_stream[100];
char input_stream[100];
char decoded_stream[256];
int test,count,cut_start,cut_end,length_of_stream,final,temp_loop_s,temp_loop_e,temp_num,comp_num,send;
void select_num(int select)
{
 int output;
 //cout<< select;
 output = select + 64;
 cout << char(output);
}
void decode()
{
cout<<"\nEnter the data stream ";//<<endl;
cin >> input_stream;
length_of_stream = strlen(input_stream);
//cout<<  length_of_stream ; //only for debugging
/********************************************
			  the code starts here...
********************************************/
count = length_of_stream;

//count -= count;
for(int ini =0; ini<=count ; ini++)
{
for(int final=1;final<count;final++)
{

strncpy(cut_stream, &input_stream[ini], final);
//cut_start = cut_start + 1;
cout << final;
/*********************************************
						  compare
*********************************************/
temp_num = atoi(cut_stream);

for(int z= 1;z<=26;z++)
{
comp_num = codes[z];
if(comp_num == temp_num)
{
send  =z;
select_num(send);
test =1;
comp_num =0;
break;
}
}

if( test ==1)
{
 test =0;
 ini = final-1; // the increment will be given on the next for loop so it is reduced here
 final =0;
  //cout<< "im in test";

 break;

}
}


}
cout<< "end";
 while(1);
}


//cout<< decoded_stream;
//while(1);

void main()
{
cut_start =0;
cut_end = 1;
 cout <<  "Huffman decoder" <<  endl;
 cout <<  "Enter the codes for a-z" <<  endl;
 for(int i =1;i<=3;i++)
 {
 cin >> codes[i];
 }


decode();
}
 
for h=1:n-1
f=f-1;
for x=1:f
for k=1:f
if c(k,h)>c(k+1,h)
d=c(k+1,h);
c(k+1,h)=c(k,h);
c(k,h)=d;
end
end
end
disp('BUBBLE SORT ENDED');
if h<n-1
d(h)=c(1,h)+c(2,h);
e(h)=c(1,h);
f(h)=c(2,h);
c(1,h+1)=d(h);
disp('sum of lowest probabilities');
for i=2:f
disp('for skipped y???');
c(i,h+1)=c(i+1,h);
disp('nxt column of c ');
disp(c(i,h+1));
end
end
end

here x and k loops are used for bubble sorting and h is used for changing columns........
the problem i'm facing is that the program is skipping the for loop within the if statement
to identify which for statement is being skipped...i've written within the for statement "for skipped y?".....
can anyone tell me what error is there that it is skipping the for loop.....there r no syntax or any such errors.....but that loop is being skipped....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top