From c5ec69f48a640c6cadc7932aceac0dc25ce824f4 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Wed, 2 Sep 2020 20:23:11 +0100 Subject: [PATCH] Headerise each file --- src/color.c | 4 +--- src/color.h | 9 +++++++++ src/common.h | 3 +++ src/filter.h | 2 +- src/filtercoeff.h | 2 +- src/image.c | 5 ++--- src/image.h | 9 +++++++++ src/main.c | 23 +++-------------------- src/median.c | 2 +- src/pngio.c | 12 +++++------- src/pngio.h | 13 +++++++++++++ src/reg.c | 3 ++- src/reg.h | 1 + src/satcal.h | 2 +- 14 files changed, 52 insertions(+), 38 deletions(-) create mode 100644 src/color.h create mode 100644 src/image.h create mode 100644 src/pngio.h create mode 100644 src/reg.h diff --git a/src/color.c b/src/color.c index 09d7860..dda501c 100644 --- a/src/color.c +++ b/src/color.c @@ -17,9 +17,7 @@ * */ -#include "common.h" - -#define MCOMPOSITE(m1, a1, m2, a2) (m1*a1 + m2*a2*(1-a1)) +#include "color.h" rgb_t applyPalette(char *palette, int val){ return (rgb_t){ diff --git a/src/color.h b/src/color.h new file mode 100644 index 0000000..499676e --- /dev/null +++ b/src/color.h @@ -0,0 +1,9 @@ +#include "common.h" + +#define MCOMPOSITE(m1, a1, m2, a2) (m1*a1 + m2*a2*(1-a1)) + +rgb_t applyPalette(char *palette, int val); +rgb_t RGBcomposite(rgb_t top, float top_a, rgb_t bottom, float bottom_a); + +char TempPalette[256*3]; +char PrecipPalette[58*3]; diff --git a/src/common.h b/src/common.h index 2f1a764..6f36d29 100644 --- a/src/common.h +++ b/src/common.h @@ -26,6 +26,8 @@ #define CONTAINS(str, char) (strchr(str, (int) char) != NULL) // Typedefs +#ifndef STRUCTS_DEFINED +#define STRUCTS_DEFINED typedef struct { float r, g, b; } rgb_t; @@ -68,3 +70,4 @@ enum effects { Linear_Equalise='l', Crop_Noise='c' }; +#endif diff --git a/src/filter.h b/src/filter.h index 4741fbc..eeec78b 100755 --- a/src/filter.h +++ b/src/filter.h @@ -19,4 +19,4 @@ float fir(float *buff, const float *coeff, const int len); void iqfir(float *buff, const float *coeff, const int len, double *I, double *Q); -float rsfir(double *buff, const float *coeff, const int len, const double offset, const double delta); \ No newline at end of file +float rsfir(double *buff, const float *coeff, const int len, const double offset, const double delta); diff --git a/src/filtercoeff.h b/src/filtercoeff.h index 59c4029..a7cf709 100755 --- a/src/filtercoeff.h +++ b/src/filtercoeff.h @@ -93,4 +93,4 @@ const float rsfilter[RSFilterLen] = { -3.37279e-04, -8.80292e-06, -3.96418e-04, -6.46202e-04, -8.02450e-04, -9.64235e-04, -1.08660e-03, -1.15302e-03, -1.23904e-03, -1.20955e-03, -1.26937e-03, -1.15443e-03, -1.19836e-03, -1.01377e-03, -1.05669e-03, -8.15327e-04, -8.79730e-04, -5.93148e-04, -6.95337e-04, -3.75376e-04, -5.27511e-04, -1.78544e-04, -3.96418e-04, -8.80292e-06, --3.37279e-04 }; \ No newline at end of file +-3.37279e-04 }; diff --git a/src/image.c b/src/image.c index 9d6ef5f..3f14cd2 100644 --- a/src/image.c +++ b/src/image.c @@ -23,16 +23,15 @@ #include #include -#include "common.h" #include "offsets.h" +#include "reg.h" +#include "image.h" #define REGORDER 3 typedef struct { double cf[REGORDER + 1]; } rgparam_t; -extern void polyreg(const int m, const int n, const double x[], const double y[], double c[]); - // Compute regression static void rgcomp(double x[16], rgparam_t * rgpr) { // { 0.106, 0.215, 0.324, 0.433, 0.542, 0.652, 0.78, 0.87, 0.0 } diff --git a/src/image.h b/src/image.h new file mode 100644 index 0000000..7397a8d --- /dev/null +++ b/src/image.h @@ -0,0 +1,9 @@ +#include "common.h" + +void histogramEqualise(float **prow, int nrow, int offset, int width); +void linearEnhance(float **prow, int nrow, int offset, int width); +int calibrate(float **prow, int nrow, int offset, int width) ; +void denoise(float **prow, int nrow, int offset, int width); +void flipImage(image_t *img, int width, int offset); +void cropNoise(image_t *img); +void temperature(options_t *opts, image_t *img, int offset, int width); diff --git a/src/main.c b/src/main.c index b7c68c2..9a2f1e1 100644 --- a/src/main.c +++ b/src/main.c @@ -27,32 +27,15 @@ #include #include -#include "common.h" #include "offsets.h" // DSP extern int init_dsp(double F); extern int getpixelrow(float *pixelv, int nrow, int *zenith, int reset); -// I/O -extern int readRawImage(char *filename, float **prow, int *nrow); -extern int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, char chid, char *palette); -extern int initWriter(options_t *opts, image_t *img, int width, int height, char *desc, char *chid); -extern void pushRow(float *row, int width); -extern void closeWriter(); - -// Image functions -extern int calibrate(float **prow, int nrow, int offset, int width); -extern void histogramEqualise(float **prow, int nrow, int offset, int width); -extern void linearEnhance(float **prow, int nrow, int offset, int width); -extern void temperature(options_t *opts, image_t *img, int offset, int width); -extern void denoise(float **prow, int nrow, int offset, int width); -extern void flipImage(image_t *img, int width, int offset); -extern void cropNoise(image_t *img); - -// Palettes -extern char GviPalette[256*3]; -extern char TempPalette[256*3]; +#include "pngio.h" +#include "image.h" +#include "color.h" // Audio file static SNDFILE *audioFile; diff --git a/src/median.c b/src/median.c index 7e774db..2d4e510 100644 --- a/src/median.c +++ b/src/median.c @@ -53,4 +53,4 @@ float quick_select(float arr[], int n) { high = hh - 1; } } -#undef ELEM_SWAP \ No newline at end of file +#undef ELEM_SWAP diff --git a/src/pngio.c b/src/pngio.c index 37981d6..7b6d07b 100644 --- a/src/pngio.c +++ b/src/pngio.c @@ -24,12 +24,10 @@ #include #include -#include "common.h" -#include "offsets.h" +#include "pngio.h" -extern char PrecipPalette[256*3]; -extern rgb_t applyPalette(char *palette, int val); -extern rgb_t RGBcomposite(rgb_t top, float top_a, rgb_t bottom, float bottom_a); +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wmissing-field-initializers" int mapOverlay(char *filename, rgb_t **crow, int nrow, int zenith, int MCIR) { FILE *fp = fopen(filename, "rb"); @@ -323,7 +321,7 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c } png_text meta[] = { - {PNG_TEXT_COMPRESSION_NONE, "Software", VERSION}, + {PNG_TEXT_COMPRESSION_NONE, "Software", VERSION, sizeof(VERSION)}, {PNG_TEXT_COMPRESSION_NONE, "Channel", desc, sizeof(desc)}, {PNG_TEXT_COMPRESSION_NONE, "Description", "NOAA satellite image", 20} }; @@ -497,7 +495,7 @@ int initWriter(options_t *opts, image_t *img, int width, int height, char *desc, sprintf(outName, "%s/%s-%s.png", opts->path, img->name, chid); png_text meta[] = { - {PNG_TEXT_COMPRESSION_NONE, "Software", VERSION}, + {PNG_TEXT_COMPRESSION_NONE, "Software", VERSION, sizeof(VERSION)}, {PNG_TEXT_COMPRESSION_NONE, "Channel", desc, sizeof(desc)}, {PNG_TEXT_COMPRESSION_NONE, "Description", "NOAA satellite image", 20} }; diff --git a/src/pngio.h b/src/pngio.h new file mode 100644 index 0000000..cdb7cfd --- /dev/null +++ b/src/pngio.h @@ -0,0 +1,13 @@ +#include "common.h" +#include "offsets.h" +#include "color.h" + +int mapOverlay(char *filename, rgb_t **crow, int nrow, int zenith, int MCIR); +int readRawImage(char *filename, float **prow, int *nrow); +int readPalette(char *filename, rgb_t **pixels); +void prow2crow(float **prow, int nrow, char *palette, rgb_t **crow); +int applyUserPalette(float **prow, int nrow, char *filename, rgb_t **crow); +int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, char chid, char *palette); +int initWriter(options_t *opts, image_t *img, int width, int height, char *desc, char *chid); +void pushRow(float *row, int width); +void closeWriter(); diff --git a/src/reg.c b/src/reg.c index 238f74f..975993f 100644 --- a/src/reg.c +++ b/src/reg.c @@ -12,9 +12,10 @@ #include +#include "reg.h" + #define DMAX 5 /* Maximum degree of polynomial */ #define NMAX 10 /* Maximum number of points */ - static void FactPiv(int N, double A[DMAX][DMAX], double B[], double Cf[]); void polyreg(const int M, const int N, const double X[], const double Y[], double C[]) { diff --git a/src/reg.h b/src/reg.h new file mode 100644 index 0000000..f18371a --- /dev/null +++ b/src/reg.h @@ -0,0 +1 @@ +void polyreg(const int M, const int N, const double X[], const double Y[], double C[]); diff --git a/src/satcal.h b/src/satcal.h index 9160f5b..2615ce1 100644 --- a/src/satcal.h +++ b/src/satcal.h @@ -122,4 +122,4 @@ const struct { }}; const float c1 = 1.1910427e-5; -const float c2 = 1.4387752; \ No newline at end of file +const float c2 = 1.4387752;