tp2.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __TP2__H__
  2. #define __TP2__H__
  3. #include <stdbool.h>
  4. #define FILTRO_C 0
  5. #define FILTRO_ASM 1
  6. typedef struct bgra_t {
  7. unsigned char b, g, r, a;
  8. } __attribute__((packed)) bgra_t;
  9. typedef struct bgra16_t {
  10. unsigned short b, g, r, a;
  11. } __attribute__((packed)) bgra16_t;
  12. typedef struct bgra32_t {
  13. unsigned int b, g, r, a;
  14. } __attribute__((packed)) bgra32_t;
  15. typedef struct bgr_t {
  16. unsigned char b, g, r;
  17. } __attribute__((packed)) bgr_t;
  18. typedef struct bgr16_t {
  19. unsigned short b, g, r;
  20. } __attribute__((packed)) bgr16_t;
  21. typedef struct bgr32_t {
  22. unsigned int b, g, r;
  23. } __attribute__((packed)) bgr32_t;
  24. typedef struct buffer_info_t
  25. {
  26. int width, height, width_with_padding;
  27. unsigned char *bytes;
  28. unsigned int tipo;
  29. } buffer_info_t;
  30. typedef struct configuracion_t
  31. {
  32. char *nombre_filtro;
  33. int tipo_filtro;
  34. buffer_info_t src, src_2, dst;
  35. void *extra_config;
  36. char *archivo_entrada;
  37. char *archivo_entrada_2;
  38. char archivo_salida[255];
  39. char *carpeta_salida;
  40. char *extra_archivo_salida;
  41. bool es_video;
  42. bool verbose;
  43. bool frames;
  44. bool nombre;
  45. int cant_iteraciones;
  46. } configuracion_t;
  47. #define SWITCH_C_ASM(config,c_ver,asm_ver) ( config->tipo_filtro == FILTRO_C ? c_ver : asm_ver )
  48. #define C_ASM(config) ( SWITCH_C_ASM(config, "C", "ASM") )
  49. typedef void (lector_params_fn_t) (configuracion_t *config, int, char *[]);
  50. typedef void (aplicador_fn_t) (configuracion_t*);
  51. typedef void (mostrador_ayuda_fn_t) (void);
  52. typedef struct filtro_t {
  53. char *nombre;
  54. lector_params_fn_t *leer_params;
  55. mostrador_ayuda_fn_t *ayuda;
  56. aplicador_fn_t *aplicador;
  57. int n_entradas;
  58. } filtro_t;
  59. #define DECLARAR_FILTRO(nombre) lector_params_fn_t leer_params_##nombre; \
  60. mostrador_ayuda_fn_t ayuda_##nombre; \
  61. aplicador_fn_t aplicar_##nombre; \
  62. int n_entradas_##nombre;
  63. #define DEFINIR_FILTRO(nombre) {#nombre, leer_params_##nombre, ayuda_##nombre, aplicar_##nombre, N_ENTRADAS_##nombre}
  64. // ~~~ declaraciones de tp2
  65. extern filtro_t filtros[];
  66. filtro_t* detectar_filtro(configuracion_t *config);
  67. void correr_filtro_imagen(configuracion_t *config, aplicador_fn_t aplicador);
  68. void imprimir_tiempos_ejecucion(unsigned long long int start, unsigned long long int end, int cant_iteraciones);
  69. // ~~~ declaraciones de cli.h ~~~
  70. void procesar_opciones(int argc, char **argv, configuracion_t *config);
  71. void imprimir_ayuda ( char *nombre_programa);
  72. #endif /* !__TP2__H__ */