Pārlūkot izejas kodu

Small bug fixes

Processing more than one image at once didn't work (quite bodgey)
MCIR would run even without a map
Error handling for map/raw images that don't exist
tags/v1.8.0
Xerbo pirms 4 gadiem
vecāks
revīzija
61fb740c19
3 mainītis faili ar 19 papildinājumiem un 9 dzēšanām
  1. +3
    -1
      dsp.c
  2. +3
    -3
      main.c
  3. +13
    -5
      pngio.c

+ 3
- 1
dsp.c Parādīt failu

@@ -210,13 +210,15 @@ int getpixelv(float *pvbuff, int count) {

// Get an entire row of pixels, aligned with sync markers
// FIXME: skips noisy lines with no findable sync marker
int getpixelrow(float *pixelv, int nrow, int *zenith) {
int getpixelrow(float *pixelv, int nrow, int *zenith, int reset) {
static float pixels[PixelLine + SyncFilterLen];
static int npv;
static int synced = 0;
static double max = 0.0;
static double minDoppler = 100;

if(reset) synced = 0;

double corr, ecorr, lcorr;
int res;



+ 3
- 3
main.c Parādīt failu

@@ -32,7 +32,7 @@

// DSP
extern int init_dsp(double F);
extern int getpixelrow(float *pixelv, int nrow, int *zenith);
extern int getpixelrow(float *pixelv, int nrow, int *zenith, int reset);

// I/O
extern int readRawImage(char *filename, float **prow, int *nrow);
@@ -156,7 +156,7 @@ static int processAudio(char *filename, options_t *opts){
// Read PNG into image buffer
printf("Reading %s\n", filename);
if(readRawImage(filename, img.prow, &img.nrow) == 0){
fprintf(stderr, "Skipping %s; see above.\n", img.name);
fprintf(stderr, "Skipping %s\n", img.name);
return 0;
}
}else{
@@ -171,7 +171,7 @@ static int processAudio(char *filename, options_t *opts){
img.prow[img.nrow] = (float *) malloc(sizeof(float) * 2150);

// Write into memory and break the loop when there are no more samples to read
if (getpixelrow(img.prow[img.nrow], img.nrow, &zenith) == 0)
if (getpixelrow(img.prow[img.nrow], img.nrow, &zenith, (img.nrow == 0)) == 0)
break;

if(opts->realtime) pushRow(img.prow[img.nrow], IMG_WIDTH);


+ 13
- 5
pngio.c Parādīt failu

@@ -33,6 +33,10 @@ extern rgb_t RGBcomposite(rgb_t top, float top_a, rgb_t bottom, float bottom_a);

int mapOverlay(char *filename, rgb_t **crow, int nrow, int zenith, int MCIR) {
FILE *fp = fopen(filename, "rb");
if(!fp) {
fprintf(stderr, "Cannot open %s\n", filename);
return 0;
}

// Create reader
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -133,6 +137,10 @@ int mapOverlay(char *filename, rgb_t **crow, int nrow, int zenith, int MCIR) {

int readRawImage(char *filename, float **prow, int *nrow) {
FILE *fp = fopen(filename, "r");
if(!fp) {
fprintf(stderr, "Cannot open %s\n", filename);
return 0;
}

// Create reader
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -205,7 +213,7 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c
FILE *pngfile;

// Reduce the width of the image to componsate for the missing telemetry
int fc = strcmp(desc, "False Color") == 0;
int fc = (chid[0] == 'c');
int greyscale = 0;
int skiptele = 0;
if(opts->effects != NULL && CONTAINS(opts->effects, 't')){
@@ -227,7 +235,7 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c
return 0;
}

if(palette == NULL && !CONTAINS(opts->effects, 'p') && !fc && opts->map[0] == '\0' && strcmp(chid, "MCIR") != 0){
if(palette == NULL && !CONTAINS(opts->effects, 'p') && !fc && opts->map[0] == '\0' && chid[0] != 'm'){
greyscale = 1;

// Greyscale image
@@ -281,11 +289,11 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c

// Map stuff
if(opts->map != NULL && opts->map[0] != '\0'){
if(mapOverlay(opts->map, crow, img->nrow, zenith, strcmp(desc, "MCIR") == 0) == 0){
fprintf(stderr, "Skipping MCIR generation; see above.\n");
if(mapOverlay(opts->map, crow, img->nrow, zenith, (chid[0] == 'm')) == 0){
fprintf(stderr, "Skipping MCIR generation.\n");
return 0;
}
}else if(strcmp(chid, "MCIR") == 0){
}else if(chid[0] == 'm'){
fprintf(stderr, "Skipping MCIR generation; no map provided.\n");
return 0;
}


Notiek ielāde…
Atcelt
Saglabāt