Skip to content

Commit

Permalink
Actualización para Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
arredgroup committed Jul 5, 2016
1 parent 2ad5f1d commit 951f1cb
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 45 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion class/ChannelSimulator/ChannelErlang.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class ChannelErlang: public Channel{
* @param list Lista de Paquetes del cual se eliminará uno por el ID
* @return list
*/
for (int i = 0; i < list.size(); i++)
for (int i = 0; (unsigned)i < list.size(); i++)
{
if(list[i].getID()==ID){
list.erase(list.begin()+i);
Expand Down
6 changes: 3 additions & 3 deletions class/ChannelSimulator/ChannelFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ChannelFile: public Channel{
return list;
}
string file = this->getExtras()[0];
file = "../../"+file;
//file = "../../"+file;
fp.open(file.c_str());
//cout << "Simulating Loss...\n";
vector<string> array;
Expand All @@ -50,7 +50,7 @@ class ChannelFile: public Channel{
while(getline(fp, line)){
array.push_back(line);
}
for (int i = 0; i < array.size(); i++)
for (int i = 0; (unsigned)i < array.size(); i++)
{
string s = array.at(i);
size_t pos=0;
Expand Down Expand Up @@ -84,7 +84,7 @@ class ChannelFile: public Channel{
* @param list Lista de Paquetes del cual se eliminará uno por el ID
* @return list
*/
for (int i = 0; i < list.size(); i++)
for (int i = 0; (unsigned)i < list.size(); i++)
{
if(list[i].getID()==ID){
list.erase(list.begin()+i-1);
Expand Down
6 changes: 3 additions & 3 deletions class/ForwardProcessing/DsjalMixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ class DsjalMixer: public ForwardProcessing{
cout << "(DSJAL): Step Parameter is minor than 0! STOP!\n";
return 1;
}
unsigned int i, j, k, _h_, _w_;
int i, j, k, _h_, _w_;
DataType * aux;
_h_=0;
_w_=0;
int width = (header->w)/(header->wb);
int height = (header->h)/(header->hb);
int indexH[(height*width)];
int indexW[(height*width)];
for (int i = 0, k=0; i < height; i=i+1)
for (i = 0, k=0; i < height; i=i+1)
{
for (int j = 0; j < width; j=j+1, k=k+1)
for (j = 0; j < width; j=j+1, k=k+1)
{
indexH[k]=i;
indexH[k]=j;
Expand Down
46 changes: 23 additions & 23 deletions class/ForwardProcessing/JpgCompressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class JpgCompressor: public ForwardProcessing{
}

bool isEmpty(int pos, vector <double> v){
for (int i = pos; i < v.size(); i+=1){
for (int i = pos; (unsigned)i < v.size(); i+=1){
if(v[i]!=0)
return false;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ class JpgCompressor: public ForwardProcessing{
void resetHuffman(int fb, int cb){
int block = (fb*jpg_width)+cb;
int size = compressed_blocks[block].size();
for(int i = 0;i < size && i < bytes_huffman[block].size() && i < bytes_before_huffman[block].size();i+=1){
for(int i = 0;i < size && (unsigned)i < bytes_huffman[block].size() && (unsigned)i < bytes_before_huffman[block].size();i+=1){
if(bytes_huffman[block][i]>0){
int bytes_b = bytes_before_huffman[block][i];
int bytes_h = bytes_huffman[block][i];
Expand Down Expand Up @@ -392,7 +392,7 @@ class JpgCompressor: public ForwardProcessing{

void calculateAllIDCT(){
image.resize(jpg_height*8);
for (int i = 0; i < image.size(); i+=1){
for (int i = 0; (unsigned)i < image.size(); i+=1){
image[i].resize(jpg_width*8);
}
for (int f = 0; f < jpg_height; f+=1){
Expand Down Expand Up @@ -428,8 +428,8 @@ class JpgCompressor: public ForwardProcessing{
}

void invertColorSpace(){
for(int i=0;i<image.size();i+=1){
for(int j=0;j<image[i].size();j+=1){
for(int i=0;(unsigned)i<image.size();i+=1){
for(int j=0;(unsigned)j<image[i].size();j+=1){
image[i][j] = YCC_to_RGB(image[i][j]);
}
}
Expand All @@ -438,18 +438,18 @@ class JpgCompressor: public ForwardProcessing{
void clearExtraPixels(){
if(extra_w>0 || extra_h>0){
image.resize((jpg_height*8)-extra_h);
for (int i = 0; i < image.size(); i+=1){
for (int i = 0; (unsigned)i < image.size(); i+=1){
image[i].resize((jpg_width*8)-extra_w);
}
}
}

void generateImage(){
new_list.clear();
for (int i = 0; i < image.size(); i+=1){
for (int j = 0; j < image[i].size(); j+=1){
for (int i = 0; (unsigned)i < image.size(); i+=1){
for (int j = 0; (unsigned)j < image[i].size(); j+=1){
vector<int> channels;
for(int c = 0; c < image[i][j].size(); c+=1)
for(int c = 0; (unsigned)c < image[i][j].size(); c+=1)
channels.push_back((int)image[i][j][c]);
DataBlock* block = new DataBlock(image[i][j].size(),channels,1,1);
new_list.push_back(block);
Expand All @@ -465,7 +465,7 @@ class JpgCompressor: public ForwardProcessing{

void readImage(vector<DataType *> *list, HEAD* header){
image.resize(image_height);
for (int i = 0; i < image.size(); i+=1){
for (int i = 0; (unsigned)i < image.size(); i+=1){
image[i].resize(image_width);
}
int w_block = 0;
Expand All @@ -485,7 +485,7 @@ class JpgCompressor: public ForwardProcessing{
for(int c = 0;c < w_block; c+=1){
Pixel px = block->at((f*h_block)+c);
vector<int> aux = px.getChannels();
for (int x = 0; x < chnl_block && x < aux.size(); x+=1){
for (int x = 0; x < chnl_block && (unsigned)x < aux.size(); x+=1){
image[(i*h_block)+f][(j*w_block)+c].push_back(aux[x]);
}
}
Expand All @@ -496,12 +496,12 @@ class JpgCompressor: public ForwardProcessing{

void generateExtraPixels(){
if(extra_w>0){
for (int i = 0; i < image.size(); i+=1){
for (int i = 0; (unsigned)i < image.size(); i+=1){
int j=image[i].size();
image[i].resize(j+extra_w);
for(int pos = 0; pos<extra_w; pos+=1){
vector <double> rgb;
for(int x =0; x < image[i][j-1].size();x+=1){
for(int x =0; (unsigned)x < image[i][j-1].size();x+=1){
rgb.push_back(image[i][j-1][x]);
}
image[i][j+pos]=rgb;
Expand All @@ -513,9 +513,9 @@ class JpgCompressor: public ForwardProcessing{
image.resize(i+extra_h);
for(int pos=0; pos < extra_h; pos+=1){
vector< vector <double>> aux;
for (int j = 0; j < image[i-1].size(); j+=1){
for (int j = 0; (unsigned)j < image[i-1].size(); j+=1){
vector <double> rgb;
for(int x =0; x < image[i-1][j].size();x+=1){
for(int x =0; (unsigned)x < image[i-1][j].size();x+=1){
rgb.push_back(image[i-1][j][x]);
}
aux.push_back(rgb);
Expand Down Expand Up @@ -560,8 +560,8 @@ class JpgCompressor: public ForwardProcessing{
}

void convertColorSpace(){
for(int i=0;i<image.size();i+=1){
for(int j=0;j<image[i].size();j+=1){
for(int i=0;(unsigned)i<image.size();i+=1){
for(int j=0;(unsigned)j<image[i].size();j+=1){
if(image[i][j].size()==3){
image[i][j] = RGB_to_YCC(image[i][j]);
}
Expand Down Expand Up @@ -669,7 +669,7 @@ class JpgCompressor: public ForwardProcessing{
}

vector<double> clearZero(vector<double> v){
for (int i = 0; i < v.size(); i+=1){
for (int i = 0; (unsigned)i < v.size(); i+=1){
if(isEmpty(i,v))
v.resize(i);
}
Expand Down Expand Up @@ -731,7 +731,7 @@ class JpgCompressor: public ForwardProcessing{
unsigned char* o_cb = (unsigned char*)malloc(sizeof(unsigned char)*(cb_data[block].size()));
unsigned char* o_cr = (unsigned char*)malloc(sizeof(unsigned char)*(cr_data[block].size()));
int extra_byte_y = 0;
for (int i = 0; i < y_data[block].size(); i+=1){
for (int i = 0; (unsigned)i < y_data[block].size(); i+=1){
if(y_data[block][i]<0){
negative_y[i]= floor((double)(y_data[block][i])/256);
extra_byte_y += floor((double)(y_data[block][i])/256);
Expand All @@ -743,7 +743,7 @@ class JpgCompressor: public ForwardProcessing{
o_y[i] = static_cast<unsigned char>(y_data[block][i]);
}
int extra_byte_cb = 0;
for (int i = 0; i < cb_data[block].size(); i+=1){
for (int i = 0; (unsigned)i < cb_data[block].size(); i+=1){
if(cb_data[block][i]<0){
negative_cb[i]= floor((double)(cb_data[block][i])/256);
extra_byte_cb += floor((double)(cb_data[block][i])/256);
Expand All @@ -755,7 +755,7 @@ class JpgCompressor: public ForwardProcessing{
o_cb[i] = static_cast<unsigned char>(cb_data[block][i]);
}
int extra_byte_cr = 0;
for (int i = 0; i < cr_data[block].size(); i+=1){
for (int i = 0; (unsigned)i < cr_data[block].size(); i+=1){
if(cr_data[block][i]<0){
negative_cr[i]= floor((double)(cr_data[block][i])/256);
extra_byte_cr+= floor((double)(cr_data[block][i])/256);
Expand Down Expand Up @@ -808,8 +808,8 @@ class JpgCompressor: public ForwardProcessing{
void generateDatabytestream(){
int hbyte = 0;
int obyte = 0;
for (int f = 0; f < compressed_blocks.size(); f+=1){
for (int c = 0; c < compressed_blocks[f].size(); c+=1){
for (int f = 0; (unsigned)f < compressed_blocks.size(); f+=1){
for (int c = 0; (unsigned)c < compressed_blocks[f].size(); c+=1){
hbyte = bytes_huffman[f][c];
obyte = bytes_before_huffman[f][c];
DataByteStream* db = new DataByteStream(compressed_blocks[f][c],obyte,hbyte);
Expand Down
4 changes: 2 additions & 2 deletions class/ForwardProcessing/MixerFromFile/MixerFromFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ class MixerFromFile: public ForwardProcessing{
list->at(iPos)=aux;
save << iPos << "-" << fPos << "\n";
}*/
for (int i = 0; i < list->size() && !read.eof(); i++)
for (int i = 0; (unsigned)i < list->size() && !read.eof(); i++)
{
getline(read, line);
vector<string> v = explode(line,'-');
for (int j = 0; i < v.size(); ++j)
for (int j = 0; (unsigned)i < v.size(); ++j)
remove(v[j].begin(), v[j].end(), ' ');
vector<string> posInit = explode(v[0],',');
int piX=atoi(posInit[0].c_str());
Expand Down
4 changes: 2 additions & 2 deletions class/Images.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Images
for(int c=0;c<wblock;c++){
vector<int> v_rgb = (e->at((r*hblock)+c)).getChannels();
int* rgb = (int*)malloc(sizeof(int)*v_rgb.size());
for(int x=0;x<v_rgb.size();x++){
for(int x=0;(unsigned)x<v_rgb.size();x++){
rgb[x]=v_rgb[x];
}
img.draw_point((j*wblock)+c,(i*hblock)+r,0,rgb);
Expand Down Expand Up @@ -266,7 +266,7 @@ class Images
for(int c=0;c<wblock;c++){
vector<int> v_rgb = (e->at((r*hblock)+c)).getChannels();
vector<int> rgb;
for(int x=0;x<v_rgb.size();x++){
for(int x=0;(unsigned)x<v_rgb.size();x++){
rgb.push_back(v_rgb[x]);
}
DataBlock * px = new DataBlock(type, rgb,1,1);
Expand Down
2 changes: 1 addition & 1 deletion class/Package.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Package
* @return size
*/
double size=0;
for(int i=0;i<elements.size();i++){
for(int i=0;(unsigned)i<elements.size();i++){
size+=elements[i]->getSize();
}
return size;
Expand Down
6 changes: 3 additions & 3 deletions class/Packetizer/FilePacketizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ class FilePacketizer: public Packetizer{
vector<DataType *> elements;
vector<int> idElements;
int pos=0;
for(int i=0;i<list.size();i++){
for(int i=0;(unsigned)i<list.size();i++){
Package aux = list[i];
elements = aux.getElements();
idElements = aux.getIdElements();
for (int j = 0; j < elements.size(); j++)
for (int j = 0; (unsigned)j < elements.size(); j++)
{
pos = idElements[j];
data[pos]=elements[j];
}
}
int good=0;
for(int i=0;i<data.size();i++){
for(int i=0;(unsigned)i<data.size();i++){
if(data.at(i)!=NULL){
good+=1;
}
Expand Down
6 changes: 3 additions & 3 deletions class/Packetizer/NormalPacketizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,18 @@ class NormalPacketizer: public Packetizer{
vector<DataType *> elements;
vector<int> idElements;
int pos=0;
for(int i=0;i<list.size();i+=1){
for(int i=0;(unsigned)i<list.size();i+=1){
Package aux = list[i];
elements = aux.getElements();
idElements = aux.getIdElements();
for (int j = 0; j < elements.size(); j++)
for (int j = 0; (unsigned)j < elements.size(); j++)
{
pos = idElements[j];
data[pos]=elements[j];
}
}
int good=0;
for(int i=0;i<data.size();i+=1){
for(int i=0;(unsigned)i<data.size();i+=1){
if(data[i]!=NULL)
good+=1;
}
Expand Down
Binary file modified experiment_two/image_received_restored.bmp
Binary file not shown.
1 change: 1 addition & 0 deletions experiment_two/resultados.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ Image Name % Pkg-Lost % Block-Lost Metric
src/6.bmp 0 0 PSNR: 43.682586
src/6.bmp 0 0 PSNR: 51.957305
src/6.bmp 0 0 PSNR: 43.907167
src/6.bmp 7.20981 8.44875 PSNR: 22.679994

4 changes: 2 additions & 2 deletions functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool readArguments(int n, char const *args[]){
}
string fpname = args[i];
ForwardProcessing* fpr = ForwardProcessingCreator::create(fpname);
if(fpr!=NULL && nArguments==argv.size()){
if(fpr!=NULL && (unsigned)nArguments==argv.size()){
fp_name.push_back(fpname);
fp.push_back(fpr);
fp_arguments.push_back(argv);
Expand Down Expand Up @@ -154,7 +154,7 @@ bool readArguments(int n, char const *args[]){
c=c+1;
}
i=i+c;
if(argu.size()==x){
if(argu.size()==(unsigned)x){
Channel* chn = ChannelCreator::create(fpname, argu);
if(chn!=NULL){
chnl=chn;
Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ using namespace std;
cout << "Arguments readed\n";
Images img(src,&header,show_data);
vector<DataType *> list = img.toList();
for (int i = 0; i < fp.size(); i=i+1)
for (int i = 0; (unsigned)i < fp.size(); i=i+1)
{
int narg = fp_narguments[i];
vector<void *> args = fp_arguments[i];
Expand Down Expand Up @@ -125,7 +125,7 @@ using namespace std;

rbd->hidden(&received,show_data,export_images,&header);

for (int i = 0; i < metrics.size(); i=i+1)
for (int i = 0; (unsigned)i < metrics.size(); i=i+1)
{
double met = metrics.at(i)->calculate(img,received,show_data,&header);
if(export_files){
Expand Down
Binary file modified simlit
Binary file not shown.

0 comments on commit 951f1cb

Please sign in to comment.