@@ -41,13 +41,17 @@ extern "C" { | |||||
// Maximum height of an APT image in number of scanlines | // Maximum height of an APT image in number of scanlines | ||||
#define APT_MAX_HEIGHT 3000 | #define APT_MAX_HEIGHT 3000 | ||||
// Width in pixels of sync | |||||
#define APT_SYNC_WIDTH 39 | #define APT_SYNC_WIDTH 39 | ||||
// Width in pixels of space | |||||
#define APT_SPC_WIDTH 47 | #define APT_SPC_WIDTH 47 | ||||
// Width in pixels of telemetry | |||||
#define APT_TELE_WIDTH 45 | #define APT_TELE_WIDTH 45 | ||||
// Width in pixels of a single channel image | // Width in pixels of a single channel image | ||||
#define APT_CH_WIDTH 909 | #define APT_CH_WIDTH 909 | ||||
#define APT_FRAME_LEN 128 | #define APT_FRAME_LEN 128 | ||||
#define APT_CH_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH) | #define APT_CH_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH) | ||||
// Width in pixels of full frame, including sync, space, images and telemetry | |||||
#define APT_IMG_WIDTH 2080 | #define APT_IMG_WIDTH 2080 | ||||
// Offset in pixels to channel A | // Offset in pixels to channel A | ||||
#define APT_CHA_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH) | #define APT_CHA_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH) | ||||
@@ -55,6 +59,9 @@ extern "C" { | |||||
#define APT_CHB_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH) | #define APT_CHB_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH) | ||||
#define APT_TOTAL_TELE (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH) | #define APT_TOTAL_TELE (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH) | ||||
// Width in elements of apt_image_t.prow arrays | |||||
#define APT_PROW_WIDTH 2150 | |||||
// apt_getpixelrow callback function to get audio samples. | // apt_getpixelrow callback function to get audio samples. | ||||
// context is the same as passed to apt_getpixelrow. | // context is the same as passed to apt_getpixelrow. | ||||
typedef int (*apt_getsamples_t)(void *context, float *samples, int count); | typedef int (*apt_getsamples_t)(void *context, float *samples, int count); | ||||
@@ -318,7 +318,7 @@ int apt_cropNoise(apt_image_t *img){ | |||||
// Remove the noisy rows at start | // Remove the noisy rows at start | ||||
for(int y = 0; y < img->nrow-startCrop; y++) { | for(int y = 0; y < img->nrow-startCrop; y++) { | ||||
memmove(img->prow[y], img->prow[y+startCrop], sizeof(float)*2150); | |||||
memmove(img->prow[y], img->prow[y+startCrop], sizeof(float)*APT_PROW_WIDTH); | |||||
} | } | ||||
// Ignore the noisy rows at the end | // Ignore the noisy rows at the end | ||||
@@ -161,7 +161,7 @@ static int processAudio(char *filename, options_t *opts){ | |||||
// TODO: multithreading, would require some sort of input buffer | // TODO: multithreading, would require some sort of input buffer | ||||
for (img.nrow = 0; img.nrow < APT_MAX_HEIGHT; img.nrow++) { | for (img.nrow = 0; img.nrow < APT_MAX_HEIGHT; img.nrow++) { | ||||
// Allocate memory for this row | // Allocate memory for this row | ||||
img.prow[img.nrow] = (float *) malloc(sizeof(float) * 2150); | |||||
img.prow[img.nrow] = (float *) malloc(sizeof(float) * APT_PROW_WIDTH); | |||||
// Write into memory and break the loop when there are no more samples to read | // Write into memory and break the loop when there are no more samples to read | ||||
if (apt_getpixelrow(img.prow[img.nrow], img.nrow, &img.zenith, (img.nrow == 0), getsamples, NULL) == 0) | if (apt_getpixelrow(img.prow[img.nrow], img.nrow, &img.zenith, (img.nrow == 0), getsamples, NULL) == 0) | ||||
@@ -216,8 +216,8 @@ static int processAudio(char *filename, options_t *opts){ | |||||
// Create another buffer as to not modify the orignal | // Create another buffer as to not modify the orignal | ||||
apt_image_t tmpimg = img; | apt_image_t tmpimg = img; | ||||
for(int i = 0; i < img.nrow; i++){ | for(int i = 0; i < img.nrow; i++){ | ||||
tmpimg.prow[i] = (float *) malloc(sizeof(float) * 2150); | |||||
memcpy(tmpimg.prow[i], img.prow[i], sizeof(float) * 2150); | |||||
tmpimg.prow[i] = (float *) malloc(sizeof(float) * APT_PROW_WIDTH); | |||||
memcpy(tmpimg.prow[i], img.prow[i], sizeof(float) * APT_PROW_WIDTH); | |||||
} | } | ||||
// Perform temperature calibration | // Perform temperature calibration | ||||