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.

apt.h 3.5 KiB

3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 scanlines
  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. // Width in elements of apt_image_t.prow arrays
  58. #define APT_PROW_WIDTH 2150
  59. // apt_getpixelrow callback function to get audio samples.
  60. // context is the same as passed to apt_getpixelrow.
  61. typedef int (*apt_getsamples_t)(void *context, float *samples, int count);
  62. typedef struct {
  63. float *prow[APT_MAX_HEIGHT]; // Row buffers
  64. int nrow; // Number of rows
  65. int zenith; // Row in image where satellite reaches peak elevation
  66. int chA, chB; // ID of each channel
  67. char name[256]; // Stripped filename
  68. char *palette; // Filename of palette
  69. } apt_image_t;
  70. typedef struct {
  71. float r, g, b;
  72. } apt_rgb_t;
  73. int APT_API apt_init(double sample_rate);
  74. int APT_API apt_getpixelrow(float *pixelv, int nrow, int *zenith, int reset, apt_getsamples_t getsamples, void *context);
  75. void APT_API apt_histogramEqualise(float **prow, int nrow, int offset, int width);
  76. void APT_API apt_linearEnhance(float **prow, int nrow, int offset, int width);
  77. int APT_API apt_calibrate(float **prow, int nrow, int offset, int width) ;
  78. void APT_API apt_denoise(float **prow, int nrow, int offset, int width);
  79. void APT_API apt_flipImage(apt_image_t *img, int width, int offset);
  80. int APT_API apt_cropNoise(apt_image_t *img);
  81. apt_rgb_t APT_API apt_applyPalette(char *palette, int val);
  82. apt_rgb_t APT_API apt_RGBcomposite(apt_rgb_t top, float top_a, apt_rgb_t bottom, float bottom_a);
  83. extern char APT_API apt_TempPalette[256*3];
  84. extern char APT_API apt_PrecipPalette[58*3];
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif