Browse Source

Add macro for width of pixel rows

tags/v1.8.0
Jon Beniston 3 years ago
parent
commit
612dc0a977
3 changed files with 11 additions and 4 deletions
  1. +7
    -0
      src/apt.h
  2. +1
    -1
      src/image.c
  3. +3
    -3
      src/main.c

+ 7
- 0
src/apt.h View File

@@ -41,13 +41,17 @@ extern "C" {

// Maximum height of an APT image in number of scanlines
#define APT_MAX_HEIGHT 3000
// Width in pixels of sync
#define APT_SYNC_WIDTH 39
// Width in pixels of space
#define APT_SPC_WIDTH 47
// Width in pixels of telemetry
#define APT_TELE_WIDTH 45
// Width in pixels of a single channel image
#define APT_CH_WIDTH 909
#define APT_FRAME_LEN 128
#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
// Offset in pixels to channel A
#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_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.
// context is the same as passed to apt_getpixelrow.
typedef int (*apt_getsamples_t)(void *context, float *samples, int count);


+ 1
- 1
src/image.c View File

@@ -318,7 +318,7 @@ int apt_cropNoise(apt_image_t *img){

// Remove the noisy rows at start
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


+ 3
- 3
src/main.c View File

@@ -161,7 +161,7 @@ static int processAudio(char *filename, options_t *opts){
// TODO: multithreading, would require some sort of input buffer
for (img.nrow = 0; img.nrow < APT_MAX_HEIGHT; img.nrow++) {
// 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
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
apt_image_t tmpimg = img;
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


Loading…
Cancel
Save