You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

115 lines
4.1 KiB

  1. /*
  2. * This file is part of Aptdec.
  3. * Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 2019-2020
  4. * Copyright (c) 2021 Jon Beniston (M7RCE)
  5. *
  6. * Aptdec is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. *
  19. */
  20. #ifndef APT_H
  21. #define APT_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #if defined (__GNUC__) && (__GNUC__ >= 4)
  26. #define APT_API __attribute__((visibility("default")))
  27. #elif defined (_MSC_VER)
  28. #ifdef APT_API_EXPORT
  29. #define APT_API __declspec(dllexport)
  30. #elif APT_API_STATIC
  31. #define APT_API
  32. #else if
  33. #define APT_API __declspec(dllimport)
  34. #endif
  35. #else
  36. #define APT_API
  37. #endif
  38. // Maximum height of an APT image in number of rows
  39. #define APT_MAX_HEIGHT 3000
  40. // Width in pixels of sync
  41. #define APT_SYNC_WIDTH 39
  42. // Width in pixels of space
  43. #define APT_SPC_WIDTH 47
  44. // Width in pixels of telemetry
  45. #define APT_TELE_WIDTH 45
  46. // Width in pixels of a single channel image
  47. #define APT_CH_WIDTH 909
  48. #define APT_FRAME_LEN 128
  49. #define APT_CH_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH)
  50. // Width in pixels of full frame, including sync, space, images and telemetry
  51. #define APT_IMG_WIDTH 2080
  52. // Offset in pixels to channel A
  53. #define APT_CHA_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH)
  54. // Offset in pixels to channel B
  55. #define APT_CHB_OFFSET (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_CH_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH)
  56. #define APT_TOTAL_TELE (APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH+APT_SYNC_WIDTH+APT_SPC_WIDTH+APT_TELE_WIDTH)
  57. // Number of rows required for apt_calibrate
  58. #define APT_CALIBRATION_ROWS 192
  59. // Channel ID returned by apt_calibrate
  60. // NOAA-15: https://nssdc.gsfc.nasa.gov/nmc/experiment/display.action?id=1998-030A-01
  61. // Channel 1: visible (0.58-0.68 um)
  62. // Channel 2: near-IR (0.725-1.0 um)
  63. // Channel 3A: near-IR (1.58-1.64 um)
  64. // Channel 3B: mid-infrared (3.55-3.93 um)
  65. // Channel 4: thermal-infrared (10.3-11.3 um)
  66. // Channel 5: thermal-infrared (11.5-12.5 um)
  67. typedef enum apt_channel {APT_CHANNEL_UNKNOWN, APT_CHANNEL_1, APT_CHANNEL_2, APT_CHANNEL_3A, APT_CHANNEL_4, APT_CHANNEL_5, APT_CHANNEL_3B} apt_channel_t;
  68. // Width in elements of apt_image_t.prow arrays
  69. #define APT_PROW_WIDTH 2150
  70. // apt_getpixelrow callback function to get audio samples.
  71. // context is the same as passed to apt_getpixelrow.
  72. typedef int (*apt_getsamples_t)(void *context, float *samples, int count);
  73. typedef struct {
  74. float *prow[APT_MAX_HEIGHT]; // Row buffers
  75. int nrow; // Number of rows
  76. int zenith; // Row in image where satellite reaches peak elevation
  77. apt_channel_t chA, chB; // ID of each channel
  78. char name[256]; // Stripped filename
  79. char *palette; // Filename of palette
  80. } apt_image_t;
  81. typedef struct {
  82. float r, g, b;
  83. } apt_rgb_t;
  84. int APT_API apt_init(double sample_rate);
  85. int APT_API apt_getpixelrow(float *pixelv, int nrow, int *zenith, int reset, apt_getsamples_t getsamples, void *context);
  86. void APT_API apt_histogramEqualise(float **prow, int nrow, int offset, int width);
  87. void APT_API apt_linearEnhance(float **prow, int nrow, int offset, int width);
  88. apt_channel_t APT_API apt_calibrate(float **prow, int nrow, int offset, int width) ;
  89. void APT_API apt_denoise(float **prow, int nrow, int offset, int width);
  90. void APT_API apt_flipImage(apt_image_t *img, int width, int offset);
  91. int APT_API apt_cropNoise(apt_image_t *img);
  92. apt_rgb_t APT_API apt_applyPalette(char *palette, int val);
  93. apt_rgb_t APT_API apt_RGBcomposite(apt_rgb_t top, float top_a, apt_rgb_t bottom, float bottom_a);
  94. extern char APT_API apt_TempPalette[256*3];
  95. extern char APT_API apt_PrecipPalette[58*3];
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif