Skip to content

Commit

Permalink
fix file names and add make video
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Cavazzoli authored and Federico Cavazzoli committed Jul 19, 2020
1 parent 68a1cbd commit cf2a0a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
21 changes: 17 additions & 4 deletions archivos_entrega/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const int OUT_FILE = 6;

unsigned char* crear_mapa(int filas, int cols) {
unsigned char *mapa = calloc(filas, cols *sizeof(unsigned char));
if(!mapa){
fprintf(stderr, "Error creando mapa. Cerrando programa...\n");
return NULL;
}
return mapa;
}

Expand Down Expand Up @@ -74,9 +78,11 @@ int vecinos(unsigned char *mapa, int x, int y,unsigned int filas,unsigned int co
return contador;
}

void avanzar(unsigned char *mapa, unsigned int filas,unsigned int cols){
int avanzar(unsigned char *mapa, unsigned int filas,unsigned int cols){
unsigned char* mapa_tmp = crear_mapa(filas, cols);

if (!mapa_tmp) {
return -1;
}
for(int i = 0; i < filas; i++) {
for (int j = 0; j < cols; j++) {
unsigned int pos = j + i * cols;
Expand All @@ -90,6 +96,7 @@ void avanzar(unsigned char *mapa, unsigned int filas,unsigned int cols){
}

free(mapa_tmp);
return 0;
}

void dump(unsigned char *mapa,unsigned int filas,unsigned int cols, FILE* pgming) {
Expand Down Expand Up @@ -155,7 +162,7 @@ void set_filename(char* filename, char** argv, int argc, int iter){

//Agrego el numero de corrida
char corrida[10];
sprintf(corrida, "_%d", iter);
sprintf(corrida, "_%05d", iter);

strcat(filename, corrida);
// Agrego la extension
Expand All @@ -172,6 +179,9 @@ int main(int argc, char** argv){
unsigned int cols = atoi(argv[COLS]);
// Construir mapa
unsigned char* mapa = crear_mapa(filas, cols);
if(!mapa){
return -1;
}

// abrir archivo
char* filename = argv[INPUT_FILE];
Expand Down Expand Up @@ -204,7 +214,10 @@ int main(int argc, char** argv){
fclose(pgming);
}

avanzar(mapa, filas, cols);
int result = avanzar(mapa, filas, cols);
if(result < 0) {
return -1;
}
k++;
}

Expand Down
3 changes: 3 additions & 0 deletions archivos_entrega/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ clean:
find . -type f -iname \*.pbm -delete
rm -rf conway output

video:
@ffmpeg -f image2 -r 1 -pattern_type glob -i '*.pbm' -vf scale=320:320 animation.avi

.PHONY: clean

0 comments on commit cf2a0a2

Please sign in to comment.