From 8d6e8be8f46d13599947a9bbaa4951bc90838782 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Mon, 16 Jan 2023 22:25:43 +0000 Subject: [PATCH 01/19] Version 2.0.0 work --- .gitignore | 51 ++- .gitmodules | 4 +- CMakeLists.txt | 130 +++---- CONTRIBUTING.md | 31 +- README.md | 123 ++++--- aptdec-cli/main.c | 490 +++++++++++++++++++++++++ aptdec-cli/pngio.c | 153 ++++++++ aptdec-cli/pngio.h | 41 +++ {src => aptdec-cli}/util.c | 11 +- {src => aptdec-cli}/util.h | 22 +- build_windows.bat | 6 +- build_windows.sh | 3 +- cmake/FindLibSndFile.cmake | 19 - {src => libaptdec}/algebra.c | 68 +++- {src => libaptdec}/algebra.h | 17 +- libaptdec/calibration.c | 121 ++++++ {src => libaptdec}/calibration.h | 10 +- libaptdec/color.c | 94 +++++ libaptdec/dsp.c | 237 ++++++++++++ libaptdec/effects.c | 175 +++++++++ libaptdec/filter.c | 109 ++++++ {src => libaptdec}/filter.h | 16 +- libaptdec/image.c | 236 ++++++++++++ libaptdec/include/aptdec.h | 169 +++++++++ libaptdec/util.c | 40 ++ libaptdec/util.h | 29 ++ luts/N19-HRPT-Falsecolor.png | Bin 0 -> 16186 bytes luts/WXtoImg-BD.png | Bin 0 -> 1613 bytes luts/WXtoImg-CC.png | Bin 0 -> 1603 bytes luts/WXtoImg-EC.png | Bin 0 -> 1632 bytes luts/WXtoImg-HE.png | Bin 0 -> 1736 bytes luts/WXtoImg-HF.png | Bin 0 -> 1683 bytes luts/WXtoImg-JF.png | Bin 0 -> 1637 bytes luts/WXtoImg-JJ.png | Bin 0 -> 1801 bytes luts/WXtoImg-MB.png | Bin 0 -> 1604 bytes luts/WXtoImg-MD.png | Bin 0 -> 1683 bytes {palettes => luts}/WXtoImg-N15-HVC.png | Bin 15665 -> 12297 bytes {palettes => luts}/WXtoImg-N18-HVC.png | Bin 15061 -> 11693 bytes {palettes => luts}/WXtoImg-N19-HVC.png | Bin 15528 -> 12160 bytes luts/WXtoImg-NO.png | Bin 0 -> 2062 bytes luts/WXtoImg-TA.png | Bin 0 -> 1553 bytes luts/WXtoImg-ZA.png | Bin 0 -> 1554 bytes {palettes => luts}/WXtoImg-class.png | Bin 13752 -> 10384 bytes luts/WXtoImg-fire.png | Bin 0 -> 1565 bytes luts/WXtoImg-sea.png | Bin 0 -> 1574 bytes palettes/N19-HRPT-Falsecolor.png | Bin 15849 -> 0 bytes palettes/WXtoImg-BD.png | Bin 4981 -> 0 bytes palettes/WXtoImg-CC.png | Bin 4971 -> 0 bytes palettes/WXtoImg-EC.png | Bin 5000 -> 0 bytes palettes/WXtoImg-HE.png | Bin 5104 -> 0 bytes palettes/WXtoImg-HF.png | Bin 5051 -> 0 bytes palettes/WXtoImg-JF.png | Bin 5005 -> 0 bytes palettes/WXtoImg-JJ.png | Bin 5169 -> 0 bytes palettes/WXtoImg-MB.png | Bin 4972 -> 0 bytes palettes/WXtoImg-MD.png | Bin 5051 -> 0 bytes palettes/WXtoImg-NO.png | Bin 5430 -> 0 bytes palettes/WXtoImg-TA.png | Bin 4921 -> 0 bytes palettes/WXtoImg-ZA.png | Bin 4922 -> 0 bytes palettes/WXtoImg-fire.png | Bin 4933 -> 0 bytes palettes/WXtoImg-sea.png | Bin 4942 -> 0 bytes src/apt.h | 126 ------- src/argparse | 1 - src/calibration.c | 101 ----- src/color.c | 83 ----- src/color.h | 3 - src/common.h | 60 --- src/dsp.c | 258 ------------- src/filter.c | 62 ---- src/image.c | 388 -------------------- src/image.h | 2 - src/libs/median.c | 56 --- src/main.c | 316 ---------------- src/pngio.c | 411 --------------------- src/pngio.h | 11 - src/taps.h | 80 ---- util/PrecipitationPalette.png | Bin 1478 -> 199 bytes util/TempPalette.png | Bin 901 -> 454 bytes util/Temperature.png | Bin 2014 -> 1596 bytes util/img2gradient.py | 37 ++ util/img2pal.py | 26 -- 80 files changed, 2240 insertions(+), 2186 deletions(-) create mode 100644 aptdec-cli/main.c create mode 100644 aptdec-cli/pngio.c create mode 100644 aptdec-cli/pngio.h rename {src => aptdec-cli}/util.c (83%) rename {src => aptdec-cli}/util.h (68%) delete mode 100644 cmake/FindLibSndFile.cmake rename {src => libaptdec}/algebra.c (56%) rename {src => libaptdec}/algebra.h (71%) create mode 100644 libaptdec/calibration.c rename {src => libaptdec}/calibration.h (87%) create mode 100644 libaptdec/color.c create mode 100644 libaptdec/dsp.c create mode 100644 libaptdec/effects.c create mode 100644 libaptdec/filter.c rename {src => libaptdec}/filter.h (66%) create mode 100644 libaptdec/image.c create mode 100644 libaptdec/include/aptdec.h create mode 100644 libaptdec/util.c create mode 100644 libaptdec/util.h create mode 100644 luts/N19-HRPT-Falsecolor.png create mode 100644 luts/WXtoImg-BD.png create mode 100644 luts/WXtoImg-CC.png create mode 100644 luts/WXtoImg-EC.png create mode 100644 luts/WXtoImg-HE.png create mode 100644 luts/WXtoImg-HF.png create mode 100644 luts/WXtoImg-JF.png create mode 100644 luts/WXtoImg-JJ.png create mode 100644 luts/WXtoImg-MB.png create mode 100644 luts/WXtoImg-MD.png rename {palettes => luts}/WXtoImg-N15-HVC.png (70%) rename {palettes => luts}/WXtoImg-N18-HVC.png (70%) rename {palettes => luts}/WXtoImg-N19-HVC.png (71%) create mode 100644 luts/WXtoImg-NO.png create mode 100644 luts/WXtoImg-TA.png create mode 100644 luts/WXtoImg-ZA.png rename {palettes => luts}/WXtoImg-class.png (63%) create mode 100644 luts/WXtoImg-fire.png create mode 100644 luts/WXtoImg-sea.png delete mode 100644 palettes/N19-HRPT-Falsecolor.png delete mode 100644 palettes/WXtoImg-BD.png delete mode 100644 palettes/WXtoImg-CC.png delete mode 100644 palettes/WXtoImg-EC.png delete mode 100644 palettes/WXtoImg-HE.png delete mode 100644 palettes/WXtoImg-HF.png delete mode 100644 palettes/WXtoImg-JF.png delete mode 100644 palettes/WXtoImg-JJ.png delete mode 100644 palettes/WXtoImg-MB.png delete mode 100644 palettes/WXtoImg-MD.png delete mode 100644 palettes/WXtoImg-NO.png delete mode 100644 palettes/WXtoImg-TA.png delete mode 100644 palettes/WXtoImg-ZA.png delete mode 100644 palettes/WXtoImg-fire.png delete mode 100644 palettes/WXtoImg-sea.png delete mode 100644 src/apt.h delete mode 160000 src/argparse delete mode 100644 src/calibration.c delete mode 100644 src/color.c delete mode 100644 src/color.h delete mode 100644 src/common.h delete mode 100644 src/dsp.c delete mode 100644 src/filter.c delete mode 100644 src/image.c delete mode 100644 src/image.h delete mode 100644 src/libs/median.c delete mode 100644 src/main.c delete mode 100644 src/pngio.c delete mode 100644 src/pngio.h delete mode 100644 src/taps.h create mode 100755 util/img2gradient.py delete mode 100644 util/img2pal.py diff --git a/.gitignore b/.gitignore index 85d013c..69c083f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ -# Created by https://www.gitignore.io/api/c -# Edit at https://www.gitignore.io/?templates=c +# Created by https://www.toptal.com/developers/gitignore/api/c,cmake +# Edit at https://www.toptal.com/developers/gitignore?templates=c,cmake + +### C ### +# Prerequisites +*.d # Object files *.o @@ -26,6 +30,7 @@ *.dll *.so *.so.* +*.dylib # Executables *.exe @@ -33,6 +38,7 @@ *.app *.i*86 *.x86_64 +*.hex # Debug files *.dSYM/ @@ -40,19 +46,40 @@ *.idb *.pdb -# Program specifics +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +# External projects +*-prefix/ + +# End of https://www.toptal.com/developers/gitignore/api/c,cmake + *.png !textlogo.png -!palettes/*.png +!luts/*.png !util/*.png + *.wav -aptdec +*.ogg -.vscode/ build/ -libpng/ -zlib/ -winbuild/ -winpath/ -libsndfile-1.0.29-win64.zip -libsndfile-1.0.29-win64/ diff --git a/.gitmodules b/.gitmodules index f1e9861..619fa46 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "src/argparse"] - path = src/argparse +[submodule "aptdec-cli/argparse"] + path = aptdec-cli/argparse url = https://github.com/cofyc/argparse diff --git a/CMakeLists.txt b/CMakeLists.txt index adf190c..843a97d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,81 +1,86 @@ -cmake_minimum_required (VERSION 3.0.0) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +cmake_minimum_required(VERSION 3.0.0) -project(aptdec C) +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_EXTENSIONS OFF) + +# Get version +find_package(Git) +if (GIT_FOUND) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --tag WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) + set(VERSION "${GIT_TAG}") +else() + set(VERSION "Unknown") +endif() +project(aptdec C) include(GNUInstallDirs) -# libpng +# aptdec-cli find_package(PNG) - -# libsndfile -find_package(LibSndFile) - -set(LIB_C_SOURCE_FILES src/color.c src/dsp.c src/filter.c src/image.c src/algebra.c src/libs/median.c src/util.c src/calibration.c) -set(EXE_C_SOURCE_FILES src/main.c src/pngio.c src/argparse/argparse.c src/util.c) -set(LIB_C_HEADER_FILES src/apt.h) - -# Link with static library for aptdec executable, so we don't need to set the path -add_library(aptstatic STATIC ${LIB_C_SOURCE_FILES}) - -# Create shared library for 3rd party apps -add_library(apt SHARED ${LIB_C_SOURCE_FILES}) -set_target_properties(apt PROPERTIES PUBLIC_HEADER ${LIB_C_HEADER_FILES}) - -add_compile_definitions(PALETTE_DIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/palettes") - -if (PNG_FOUND AND LIBSNDFILE_FOUND) - add_executable(aptdec ${EXE_C_SOURCE_FILES}) - include_directories(${PNG_PNG_INCLUDE_DIR}) - include_directories(${LIBSNDFILE_INCLUDE_DIR}) - target_link_libraries(aptdec PRIVATE PNG::PNG) - target_link_libraries(aptdec PRIVATE ${LIBSNDFILE_LIBRARY}) - target_link_libraries(aptdec PRIVATE aptstatic) - if (MSVC) - target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC) +find_path(SNDFILE_INCLUDE_DIR sndfile.h) +find_library(SNDFILE_LIBRARIES NAMES sndfile libsndfile PATH) + +if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR) + set(APTDEC_CLI_SOURCE_FILES + aptdec-cli/argparse/argparse.c + aptdec-cli/main.c + aptdec-cli/pngio.c + aptdec-cli/util.c + ) + add_executable(aptdec-cli ${APTDEC_CLI_SOURCE_FILES}) + + target_compile_definitions(aptdec-cli PRIVATE "VERSION=\"${VERSION}\"") + target_include_directories(aptdec-cli PRIVATE ${PNG_INCLUDE_DIRS}) + target_include_directories(aptdec-cli PRIVATE ${SNDFILE_INCLUDE_DIR}) + target_include_directories(aptdec-cli PRIVATE libaptdec/include/) + target_link_libraries(aptdec-cli PRIVATE ${PNG_LIBRARIES}) + target_link_libraries(aptdec-cli PRIVATE ${SNDFILE_LIBRARIES}) + target_link_libraries(aptdec-cli PRIVATE aptdec) + + if(MSVC) + target_compile_options(aptdec-cli PRIVATE /D_CRT_SECURE_NO_WARNINGS=1) else() - # Math - target_link_libraries(aptdec PRIVATE m) - - # Throw errors on warnings on release builds - if(CMAKE_BUILD_TYPE MATCHES "Release") - target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) - else() - target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) - endif() + target_link_libraries(aptdec-cli PRIVATE m) + target_compile_options(aptdec-cli PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() else() - MESSAGE(WARNING "Only building apt library, as not all of the required libraries were found for aptdec.") + message(WARNING "Not building aptdec-cli as some/all required dependencies are missing, libaptdec will still be built") endif() -if (MSVC) - target_compile_options(apt PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_EXPORT) - target_compile_options(aptstatic PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPT_API_STATIC) +# libaptdec +set(LIBAPTDEC_HEADER_FILES libaptdec/include/aptdec.h) +set(LIBAPTDEC_SOURCE_FILES + libaptdec/algebra.c + libaptdec/calibration.c + libaptdec/color.c + libaptdec/dsp.c + libaptdec/filter.c + libaptdec/image.c + libaptdec/util.c + libaptdec/effects.c +) +add_library(aptdec SHARED ${LIBAPTDEC_SOURCE_FILES}) + +set_target_properties(aptdec PROPERTIES PUBLIC_HEADER ${LIBAPTDEC_HEADER_FILES}) +target_include_directories(aptdec PRIVATE libaptdec/include/) +target_compile_definitions(aptdec PRIVATE "VERSION=\"${VERSION}\"") + +if(MSVC) + target_compile_options(aptdec PRIVATE /D_CRT_SECURE_NO_WARNINGS=1 /DAPTDEC_API_EXPORT) else() - # Math - target_link_libraries(apt PRIVATE m) - target_link_libraries(aptstatic PRIVATE m) - - if(CMAKE_BUILD_TYPE MATCHES "Release") - target_compile_options(apt PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) - else() - target_compile_options(apt PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) - endif() + target_link_libraries(aptdec PRIVATE m) + target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() -# TODO: get this from git -set(PROJECT_VERSION "1.7.0") - -# CPack -set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +# Packaging +set(CPACK_PACKAGE_VERSION "${VERSION}") set(CPACK_PACKAGE_NAME "aptdec") set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder") -set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS program that decodes images transmitted by NOAA weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.") -set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") +set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS library/program that decodes images transmitted by the NOAA POES weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.") set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) -IF(NOT WIN32) +if(NOT WIN32) set(CPACK_GENERATOR "DEB;TGZ") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}") else() @@ -89,11 +94,10 @@ else() endif() endif() -if (TARGET aptdec) +if(TARGET aptdec-cli) install(TARGETS aptdec RUNTIME DESTINATION bin) - install(DIRECTORY "${PROJECT_SOURCE_DIR}/palettes" DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}) endif() -install(TARGETS apt PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt LIBRARY DESTINATION lib) +install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) include(CPack) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff8b624..988ccf9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,28 +1,27 @@ # How To Contribute -Thank you for showing interest to contributing to aptdec, these guidelines layout how you should go about reporting issues and contributing. +Thanks for showing an interest in improving aptdec, these guidelines outline how you should go about contributing to the project. -## Did you Find A Bug? +## Did you find a bug? -1. Ensure the bug was not already reported by searching on GitHub under Issues. -2. If you're unable to find an closed issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible and an audio file that demonstrates what is unexpected behaviour. -3. If possible, use the report templates to create the issue. +1. Make sure the bug has not already been reported +2. If an issue already exists, leave a thumbs up to "bump" the issue +3. If an issue doesn't exist, open a new one with a clear title and description and, if relevant, any files that cause the behavior -## Do you have a patch that fixes a bug? +## Do you have a patch that fixes a bug/adds a feature? -1. Fork the repository and push your changes on a new branch. -2. Add your changes on that branch, make sure to use sensible commit names. -3. Open a new GitHub pull request to pull into master. -4. Ensure the pull request description clearly describes the problem and solution. Include the relevant issue number if applicable. +1. Fork this repository and put your changes on a *new branch* +2. Make sure to use sensible commit names +3. Open a new pull request into master + +If you don't have a GitHub account, you can email me the patch at `xerbo (at) protonmail (dot) com` ## Coding style -- Whitespaces should be denoted with tabs -- This is FOSS software, consider that people will read your code, so make it easily readable. -- If you're making major changes, make sure to create an issue to discuss it. +The coding style of LeanHRPT is based off the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) with minor modifications (see `.clang-format`), in addition to this all files should use LF line endings and end in a newline. Use American english (i.e. "color", not "colour"). ## Commit message style -- Keep titles under 80 characters to prevent wrapping. -- Make sure the commit message is descriptive of the change, dont be afraid to go into detail. -- Split up large changes into multiple commits. +- Keep titles short to prevent wrapping (descriptions exist) +- Split up large changes into multiple commits +- Never use hastags for sequential counting in commits, as this interferes with issue/PR referencing diff --git a/README.md b/README.md index 7865e84..1d8acab 100644 --- a/README.md +++ b/README.md @@ -6,58 +6,63 @@ Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 20 ## Introduction -Aptdec is a FOSS program that decodes images transmitted by NOAA weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT. -These transmissions can easily be received with a cheap SDR and simple antenna. Then the transmission can be decoded in narrow FM mode. +Aptdec is a FOSS library/program that decodes images transmitted by the NOAA POES weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT. +These transmissions can easily be received with a cheap SDR and simple antenna, the transmission can be demodulated in narrow FM mode. -Aptdec can turn the audio recordings into PNG images and generate images such as: +Aptdec can turn the audio into PNG images and generate other products such as: - - Raw image: both channels with full telemetry included - - Individual channel: one of the channels form the image - - Temperature image: a temperature compensated image derived from the IR channel - - Palleted image: a image where the color is derived from a palette (false color, etc) + - Raw image: both channels (including telemetry) + - Individual channel: one channel (including telemetry) + - Visible image: a calibrated visible image of either channel 1 or 2 + - Thermal image: a calibrated thermal image from channel B + - LUT image: a image where the color is derived from a LUT (used for false color, etc) -The input audio format can be anything supported by `libsndfile` (although only tested with WAV and FLAC). Sample rate doesn't matter, although lower samples rates will process faster. +The input audio format can be anything supported by `libsndfile` (although only tested with WAV, FLAC and Ogg Vorbis). While sample rate doesn't matter, it is recommended to use 16640 Hz (4x oversampling). ## Quick start +Grab a release from [Releases](https://github.com/Xerbo/aptdec/releases) or compile from source: + ```sh sudo apt install cmake git gcc libsndfile-dev libpng-dev git clone --recursive https://github.com/Xerbo/aptdec.git && cd aptdec cmake -B build cmake --build build -# Resulting binary is build/aptdec +# Resulting binary is build/aptdec-cli ``` +In place builds are not supported. + ## Examples -To create an image from `gqrx_20200527_115730_137914960.wav` (output filename will be `gqrx_20200527_115730_137914960-r.png`) +To create an image from `gqrx_20200527_115730_137914960.wav` (output filename will be `gqrx_20200527_115730_137914960-raw.png`) ```sh -./aptdec gqrx_20200527_115730_137914960.wav +aptdec-cli gqrx_20200527_115730_137914960.wav ``` -To manually set the output filename +To manually specify the output filename ```sh -./aptdec -o image.png gqrx_20200527_115730_137914960.wav +aptdec-cli -o image.png gqrx_20200527_115730_137914960.wav ``` -Decode all WAV files in the current directory and put them in `images` +Decode all WAV files in the current directory: ```sh -mkdir images && ./aptdec -d images *.wav +aptdec-cli *.wav ``` Apply a denoise filter (see [Post-Processing Effects](#post-processing-effects) for a full list of post-processing effects) ```sh -./aptdec -e d gqrx_20200527_115730_137914960.wav +aptdec-cli -e denoise gqrx_20200527_115730_137914960.wav ``` -Create a temperature compensated image for NOAA 18 +Create a calibrated IR image from NOAA 18 ```sh -./aptdec -i t -s 18 gqrx_20200527_115730_137914960.wav +aptdec-cli -i thermal gqrx_20200527_115730_137914960.wav ``` -Apply a falsecolor palette +Apply a falsecolor LUT ```sh -./aptdec -i p -p palettes/WXtoImg-N18-HVC.png gqrx_20200527_115730_137914960.wav +aptdec-cli -i lut -l luts/WXtoImg-N18-HVC.png gqrx_20200527_115730_137914960.wav ``` ## Usage @@ -65,72 +70,74 @@ Apply a falsecolor palette ### Arguments ``` --i [r|a|b|t|m|p] Output type (stackable) --e [t|h|l|d|p|f] Effects (stackable) --o Output filename --d Destination directory --s (15-19) Satellite number --p Path to palette --r Realtime decode --g Gamma adjustment (1.0 = off) +-h, --help show a help message and exit +-i, --image= set output image type (see below) +-e, --effect= add an effect (see below) +-g, --gamma= gamma adjustment (1.0 = off) +-s, --satellite= satellite ID, must be between 15, 18 or 19 or NORAD +-l, --lut= path to a LUT +-o, --output= path of output image +-r, --realtime decode in realtime ``` ### Image output types - - `r`: Raw Image - - `a`: Channel A - - `b`: Channel B - - `t`: Temperature - - `p`: Palleted + - `raw`: Raw Image + - `a`: Channel A (including telemetry) + - `b`: Channel B (including telemetry) + - `thermal`: Calibrated thermal (MWIR/LWIR) image + - `visible`: calibrated visible/NIR image + - `lut`: LUT image, see also `-l/--lut` ### Post-Processing Effects - - `t`: Crop telemetry (only effects raw image) - - `h`: Histogram equalise - - `l`: Linear equalise - - `d`: Denoise - - `p`: Precipitation overlay - - `f`: Flip image (for northbound passes) - - `c`: Crop noise from ends of image + - `strip`: Strip telemetry (only effects raw/a/b images) + - `equalize`: Histogram equalise + - `stretch`: Linear equalise + - `denoise`: Denoise + - ~~`precipitation`: Precipitation overlay~~ + - `flip`: Flip image (for northbound passes) + - `crop`: Crop noise from ends of image ## Realtime decoding -Aptdec even supports decoding in realtime. The following decodes the audio coming from the audio device `pulseaudio alsa_output.pci-0000_00_1b.0.analog-stereo` +Aptdec supports decoding in realtime. The following captures and decodes audio from the `pipewire` interface: +```sh +arecord -f cd -D pipewire | aptdec -r - ``` -mkfifo /tmp/aptaudio -aptdec -r /tmp/aptaudio -sox -t pulseaudio alsa_output.pci-0000_00_1b.0.analog-stereo.monitor -c 1 -t wav /tmp/aptaudio + +or directly from an SDR: + +```sh +rtl_fm -f 137.1M -g 40 -s 40k | sox -t raw -r 40k -e signed-integer -b 16 - -t wav - | aptdec -r - ``` -To stop the decode and calibrate the image simply kill the `sox` process. +Image data will be streamed to `CURRENT_TIME.png` (deleted when finished). To stop the decode and normalize the image simply `Ctrl+C` the process. -## Palette formatting +## LUT format -Palettes are just simple PNG images, 256x256px in size with 24bit RGB color. The X axis represents the value of Channel A and the Y axis the value of Channel B. +LUT's are just plain PNG images, 256x256px in size with 24bit RGB color. The X axis represents the value of Channel A and the Y axis the value of Channel B. ## Building for Windows -You can cross build for Windows from Linux with the `build_windows.sh` script, you will need the following: -``` +You can cross build for Windows from Linux (recommended) using with the following commands: +```sh sudo apt install wget cmake make mingw-w64 git unzip +./build_windows.sh ``` -To build natively on Windows using MSVC, you will also need: git, ninja and cmake. Then run: +To build natively on Windows using MSVC, you will need: git, ninja and cmake. Then run: ``` .\build_windows.bat ``` -If you just wish to build libaptdec on Windows, libpng and libsndfile aren't needed. - -## Further Reading - -[User's Guide for Building and Operating -Environmental Satellite Receiving Stations](https://noaasis.noaa.gov/NOAASIS/pubs/Users_Guide-Building_Receive_Stations_March_2009.pdf) +If you only want to build libaptdec, libpng and libsndfile aren't needed. -[NOAA KLM coefficients](https://web.archive.org/web/20141220021557/https://www.ncdc.noaa.gov/oa/pod-guide/ncdc/docs/klm/tables.htm) +## References -[NOAA Satellite specifications and more information](https://www1.ncdc.noaa.gov/pub/data/satellite/publications/podguides/N-15%20thru%20N-19/pdf/) +- [User's Guide for Building and Operating Environmental Satellite Receiving Stations](https://noaasis.noaa.gov/NOAASIS/pubs/Users_Guide-Building_Receive_Stations_March_2009.pdf) +- [NOAA KLM Users Guide](https://archive.org/details/noaa-klm-guide) ## License diff --git a/aptdec-cli/main.c b/aptdec-cli/main.c new file mode 100644 index 0000000..7441354 --- /dev/null +++ b/aptdec-cli/main.c @@ -0,0 +1,490 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#ifndef _MSC_VER +#include +#else +#include +#endif +#include +#include +#include +#include +#include +#include + +#include "argparse/argparse.h" +#include "pngio.h" +#include "util.h" + +// Maximum height of an APT image that can be decoded +#define APTDEC_MAX_HEIGHT 3000 + +#define STRING_SPLIT(src, dst, delim, n) \ +char *dst[n]; \ +size_t dst##_len = 0; \ +{char *token = strtok(src, delim); \ +while (token != NULL && dst##_len < n) { \ + dst[dst##_len++] = token; \ + token = strtok(NULL, delim); \ +}} + +typedef struct { + char *type; // Output image type + char *effects; // Effects on the image + int satellite; // The satellite number + int realtime; // Realtime decoding + char *filename; // Output filename + char *lut; // Filename of lut +} options_t; + +typedef struct { + SNDFILE *file; + SF_INFO info; +} SNDFILE_t; + +// Function declarations +static int process_file(const char *path, options_t *opts); +static int freq_from_filename(const char *filename); +static int satid_from_freq(int freq); +static size_t callback(float *samples, size_t count, void *context); +static void write_line(writer_t *png, float *row); + +static volatile int sigint_stop = 0; +void sigint_handler(int signum) { + (void)signum; + sigint_stop = 1; +} + +// Basename is unsupported by MSVC +// This implementation is GNU style +#ifdef _MSC_VER +char *basename(const char *filename) { + char *p = strrchr(filename, '/'); + return p ? p + 1 : (char *)filename; +} +#endif + +int main(int argc, const char **argv) { + char version[128]; + get_version(version); + printf("%s\n", version); + // clang-format off + options_t opts = { + .type = "raw", + .effects = "", + .satellite = 0, + .realtime = 0, + .filename = "", + .lut = "", + }; + // clang-format on + + static const char *const usages[] = { + "aptdec-cli [options] [[--] sources]", + "aptdec-cli [sources]", + NULL, + }; + + struct argparse_option options[] = { + OPT_HELP(), + OPT_GROUP("Image options"), + OPT_STRING('i', "image", &opts.type, "set output image type (see the README for a list)", NULL, 0, 0), + OPT_STRING('e', "effect", &opts.effects, "add an effect (see the README for a list)", NULL, 0, 0), + OPT_GROUP("Satellite options"), + OPT_INTEGER('s', "satellite", &opts.satellite, "satellite ID, must be either NORAD or between 15 and 19", NULL, 0, 0), + OPT_GROUP("Paths"), + OPT_STRING('l', "lut", &opts.lut, "path to a LUT", NULL, 0, 0), + OPT_STRING('o', "output", &opts.filename, "path of output image", NULL, 0, 0), + OPT_GROUP("Misc"), + OPT_BOOLEAN('r', "realtime", &opts.realtime, "decode in realtime", NULL, 0, 0), + OPT_END(), + }; + + struct argparse argparse; + argparse_init(&argparse, options, usages, 0); + argparse_describe(&argparse, + "\nA lightweight FOSS NOAA APT satellite imagery decoder.", + "\nSee `README.md` for a full description of command line arguments and `LICENSE` for licensing conditions." + ); + argc = argparse_parse(&argparse, argc, argv); + + if (argc == 0) { + argparse_usage(&argparse); + } + if (argc > 1 && opts.realtime) { + error("Cannot use -r/--realtime with multiple input files"); + } + + // Actually decode the files + for (int i = 0; i < argc; i++) { + if (opts.satellite == 25338) opts.satellite = 15; + if (opts.satellite == 28654) opts.satellite = 18; + if (opts.satellite == 33591) opts.satellite = 19; + + if (opts.satellite == 0) { + int freq = freq_from_filename(argv[i]); + if (freq == 0) { + opts.satellite = 19; + warning("Satellite not specified, defaulting to NOAA-19"); + } else { + opts.satellite = satid_from_freq(freq); + printf("Satellite not specified, choosing to NOAA-%i based on filename\n", opts.satellite); + } + } + + if (opts.satellite != 15 && opts.satellite != 18 && opts.satellite != 19) { + error("Invalid satellite ID"); + } + + process_file(argv[i], &opts); + } + + return 0; +} + +static int process_file(const char *path, options_t *opts) { + const char *path_basename = basename((char *)path); + const char *dot = strrchr(path_basename, '.'); + char name[256]; + if (dot == NULL) { + strncpy(name, path_basename, 255); + } else { + strncpy(name, path_basename, clamp_int(dot - path_basename, 0, 255)); + } + + // Set filename to time when reading from stdin + if (strcmp(name, "-") == 0) { + time_t t = time(NULL); + strcpy(name, ctime(&t)); + } + + writer_t *realtime_png; + if (opts->realtime) { + char filename[269]; + sprintf(filename, "%s-decoding.png", name); + realtime_png = writer_init(filename, APT_REGION_FULL, APTDEC_MAX_HEIGHT, PNG_COLOR_TYPE_GRAY, "Unknown"); + + // Capture Ctrl+C + signal(SIGINT, sigint_handler); + } + + // Create a libsndfile instance + SNDFILE_t audioFile; + audioFile.file = sf_open(path, SFM_READ, &audioFile.info); + if (audioFile.file == NULL) { + error_noexit("Could not open file"); + return 0; + } + + printf("Input file: %s\n", path_basename); + printf("Input sample rate: %d\n", audioFile.info.samplerate); + + // Create a libaptdec instances + aptdec_t *aptdec = aptdec_init(audioFile.info.samplerate); + if (aptdec == NULL) { + sf_close(audioFile.file); + error_noexit("Error initializing libaptdec, sample rate too high/low?"); + return 0; + } + + // Decode image + float *data = (float *)malloc(APT_IMG_WIDTH * (APTDEC_MAX_HEIGHT+1) * sizeof(float)); + size_t rows; + for (rows = 0; rows < APTDEC_MAX_HEIGHT; rows++) { + float *row = &data[rows * APT_IMG_WIDTH]; + + // Break the loop when there are no more samples or the process has been sent SIGINT + if (aptdec_getrow(aptdec, row, callback, &audioFile) == 0 || sigint_stop) { + break; + } + + if (opts->realtime) { + write_line(realtime_png, row); + } + + fprintf(stderr, "Row: %zu/%zu\r", rows+1, audioFile.info.frames/audioFile.info.samplerate * 2); + fflush(stderr); + } + printf("\n"); + + // Close stream + sf_close(audioFile.file); + aptdec_free(aptdec); + + if (opts->realtime) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + writer_free(realtime_png); +#pragma GCC diagnostic pop + + char filename[269]; + sprintf(filename, "%s-decoding.png", name); + remove(filename); + } + + // Normalize + int error; + apt_image_t img = apt_normalize(data, rows, opts->satellite, &error); + if (error) { + error_noexit("Normalization failed"); + return 0; + } + + // clang-format off + const char *channel_name[] = { "?", "1", "2", "3A", "4", "5", "3B" }; + const char *channel_desc[] = { + "unknown", + "visible (0.58-0.68 um)", + "near-infrared (0.725-1.0 um)", + "near-infrared (1.58-1.64 um)", + "thermal-infrared (10.3-11.3 um)", + "thermal-infrared (11.5-12.5 um)", + "mid-infrared (3.55-3.93 um)" + }; + + printf("Channel A: %s - %s\n", channel_name[img.ch[0]], channel_desc[img.ch[0]]); + printf("Channel B: %s - %s\n", channel_name[img.ch[1]], channel_desc[img.ch[1]]); + // clang-format on + + STRING_SPLIT(opts->type, images, ",", 10) + STRING_SPLIT(opts->effects, effects, ",", 10) + STRING_SPLIT(opts->filename, filenames, ",", 10) + + for (size_t i = 0; i < effects_len; i++) { + if (strcmp(effects[i], "crop") == 0) { + apt_crop(&img); + } else if (strcmp(effects[i], "denoise") == 0) { + apt_denoise(&img, APT_REGION_CHA); + apt_denoise(&img, APT_REGION_CHB); + } else if (strcmp(effects[i], "flip") == 0) { + apt_flip(&img, APT_REGION_CHA); + apt_flip(&img, APT_REGION_CHB); + } + } + + for (size_t i = 0; i < images_len; i++) { + const char *base; + if (i < filenames_len) { + base = filenames[i]; + } else { + base = name; + } + + if (strcmp(images[i], "thermal") == 0) { + if (img.ch[1] >= 4) { + char filename[269]; + sprintf(filename, "%s-thermal.png", base); + char description[128]; + sprintf(description, "Calibrated thermal image, channel %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]); + + // Perform visible calibration + apt_image_t _img = apt_image_clone(img); + apt_calibrate_thermal(&_img, APT_REGION_CHA); + + writer_t *writer = writer_init(filename, APT_REGION_CHB, img.rows, PNG_COLOR_TYPE_RGB, description); + writer_write_image_gradient(writer, &_img, temperature_gradient); + writer_free(writer); + + free(_img.data); + } else { + error_noexit("Could not generate thermal image, no infrared channel"); + } + } else if (strcmp(images[i], "visible") == 0) { + if (img.ch[0] <= 2) { + char filename[269]; + sprintf(filename, "%s-visible.png", base); + char description[128]; + sprintf(description, "Calibrated visible image, channel %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]); + + // Perform visible calibration + apt_image_t _img = apt_image_clone(img); + apt_calibrate_visible(&_img, APT_REGION_CHA); + + writer_t *writer = writer_init(filename, APT_REGION_CHA, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &_img); + writer_free(writer); + + free(_img.data); + } else { + error_noexit("Could not generate visible image, no visible channel"); + } + } + } + + for (size_t i = 0; i < effects_len; i++) { + if (strcmp(effects[i], "stretch") == 0) { + apt_stretch(&img, APT_REGION_CHA); + apt_stretch(&img, APT_REGION_CHB); + } else if (strcmp(effects[i], "equalize") == 0) { + apt_equalize(&img, APT_REGION_CHA); + apt_equalize(&img, APT_REGION_CHB); + } + } + + for (size_t i = 0; i < images_len; i++) { + const char *base; + if (i < filenames_len) { + base = filenames[i]; + } else { + base = name; + } + + if (strcmp(images[i], "raw") == 0) { + char filename[269]; + sprintf(filename, "%s-raw.png", base); + char description[128]; + sprintf(description, + "Raw image, channel %s - %s / %s - %s", + channel_name[img.ch[0]], + channel_desc[img.ch[0]], + channel_name[img.ch[1]], + channel_desc[img.ch[1]] + ); + + writer_t *writer = writer_init(filename, APT_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &img); + writer_free(writer); + } else if (strcmp(images[i], "lut") == 0) { + if (opts->lut != NULL && opts->lut[0] != '\0') { + char filename[269]; + sprintf(filename, "%s-lut.png", base); + char description[128]; + sprintf(description, + "LUT image, channel %s - %s / %s - %s", + channel_name[img.ch[0]], + channel_desc[img.ch[0]], + channel_name[img.ch[1]], + channel_desc[img.ch[1]] + ); + + png_colorp lut = (png_colorp)malloc(sizeof(png_color)*256*256); + if (read_lut(opts->lut, lut)) { + writer_t *writer = writer_init(filename, APT_REGION_CHA, img.rows, PNG_COLOR_TYPE_RGB, description); + writer_write_image_lut(writer, &img, lut); + writer_free(writer); + } + free(lut); + } else { + warning("Cannot create LUT image, missing -l/--lut"); + } + } else if (strcmp(images[i], "a") == 0) { + char filename[269]; + sprintf(filename, "%s-a.png", base); + char description[128]; + sprintf(description, "Channel A: %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]); + + writer_t *writer = writer_init(filename, APT_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &img); + writer_free(writer); + } else if (strcmp(images[i], "b") == 0) { + char filename[269]; + sprintf(filename, "%s-b.png", base); + char description[128]; + sprintf(description, "Channel B: %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]); + + writer_t *writer = writer_init(filename, APT_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &img); + writer_free(writer); + } + } + + free(img.data); + return 1; +} + +static int freq_from_filename(const char *filename) { + char frequency_text[10] = {'\0'}; + + if (strlen(filename) >= 30+4 && strncmp(filename, "gqrx_", 5) == 0) { + memcpy(frequency_text, &filename[21], 9); + return atoi(frequency_text); + } else if (strlen(filename) == 40+4 && strncmp(filename, "SDRSharp_", 9) == 0) { + memcpy(frequency_text, &filename[26], 9); + return atoi(frequency_text); + } else if (strlen(filename) == 37+4 && strncmp(filename, "audio_", 6) == 0) { + memcpy(frequency_text, &filename[6], 9); + return atoi(frequency_text); + } + + return 0; +} + +static int satid_from_freq(int freq) { + int differences[3] = { + abs(freq - 137620000), // NOAA-15 + abs(freq - 137912500), // NOAA-18 + abs(freq - 137100000) // NOAA-19 + }; + + int best = 0; + for (size_t i = 0; i < 3; i++) { + if (differences[i] < differences[best]) { + best = i; + } + } + + const int lut[3] = {15, 18, 19}; + return lut[best]; +} + +// Read samples from a SNDFILE_t instance (passed through context) +static size_t callback(float *samples, size_t count, void *context) { + SNDFILE_t *file = (SNDFILE_t *)context; + + switch (file->info.channels) { + case 1: + return sf_read_float(file->file, samples, count); + case 2: { + float _samples[count * 2]; + size_t read = sf_read_float(file->file, _samples, count * 2); + + for (size_t i = 0; i < count; i++) { + // Average of left and right + samples[i] = (_samples[i*2] + _samples[i*2 + 1]) / 2.0f; + } + return read / 2; + } + default: + error_noexit("Only mono and stereo audio files are supported\n"); + return 0; + } +} + +// Write a line with very basic equalization +static void write_line(writer_t *png, float *row) { + float min = FLT_MAX; + float max = FLT_MIN; + for (int i = 0; i < APT_IMG_WIDTH; i++) { + if (row[i] < min) min = row[i]; + if (row[i] > max) max = row[i]; + } + + png_byte pixels[APT_IMG_WIDTH]; + for (int i = 0; i < APT_IMG_WIDTH; i++) { + pixels[i] = clamp_int(roundf((row[i]-min) / (max-min) * 255.0f), 0, 255); + } + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" + png_write_row(png->png, pixels); +#pragma GCC diagnostic pop +} diff --git a/aptdec-cli/pngio.c b/aptdec-cli/pngio.c new file mode 100644 index 0000000..b267d12 --- /dev/null +++ b/aptdec-cli/pngio.c @@ -0,0 +1,153 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "pngio.h" + +#include +#include +#include + +#include "util.h" + +writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height, int color, char *channel) { + writer_t *png = (writer_t *)malloc(sizeof(writer_t)); + png->region = region; + + // Create writer + png->png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png->png) { + error_noexit("Could not create PNG write struct"); + return NULL; + } + + png->info = png_create_info_struct(png->png); + if (!png->info) { + error_noexit("Could not create PNG info struct"); + return NULL; + } + + png_set_IHDR(png->png, png->info, png->region.width, height, 8, color, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + char version[128]; + int version_len = get_version(version); + + png_text text[] = { + {PNG_TEXT_COMPRESSION_NONE, "Software", version, version_len}, + {PNG_TEXT_COMPRESSION_NONE, "Channel", channel, strlen(channel)} + }; + png_set_text(png->png, png->info, text, 2); + + png->file = fopen(filename, "wb"); + if (!png->file) { + error_noexit("Could not open PNG file"); + return NULL; + } + png_init_io(png->png, png->file); + png_write_info(png->png, png->info); + + printf("Writing %s...\n", filename); + return png; +} + +void writer_write_image(writer_t *png, const apt_image_t *img) { + for (size_t y = 0; y < img->rows; y++) { + png_write_row(png->png, &img->data[y*APT_IMG_WIDTH + png->region.offset]); + } +} + +void writer_write_image_gradient(writer_t *png, const apt_image_t *img, const uint32_t *gradient) { + for (size_t y = 0; y < img->rows; y++) { + png_color pixels[APT_IMG_WIDTH]; + for (size_t x = 0; x < APT_IMG_WIDTH; x++) { + apt_rgb_t pixel = apt_gradient(gradient, img->data[y*APT_IMG_WIDTH + x + png->region.offset]); + pixels[x] = (png_color){ pixel.r, pixel.g, pixel.b }; + } + + png_write_row(png->png, (png_bytep)pixels); + } +} + +void writer_write_image_lut(writer_t *png, const apt_image_t *img, const png_colorp lut) { + for (size_t y = 0; y < img->rows; y++) { + png_color pixels[APT_CH_WIDTH]; + for (size_t x = 0; x < APT_CH_WIDTH; x++) { + uint8_t a = img->data[y*APT_IMG_WIDTH + x + APT_CHA_OFFSET]; + uint8_t b = img->data[y*APT_IMG_WIDTH + x + APT_CHB_OFFSET]; + pixels[x] = lut[b*256 + a]; + } + + png_write_row(png->png, (png_bytep)pixels); + } +} + +void writer_free(writer_t *png) { + png_write_end(png->png, png->info); + png_destroy_write_struct(&png->png, &png->info); + fclose(png->file); + free(png); +} + +int read_lut(const char *filename, png_colorp out) { + png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png) { + error_noexit("Could not create PNG read struct"); + return 0; + } + png_infop info = png_create_info_struct(png); + if (!info) { + error_noexit("Could not create PNG info struct"); + return 0; + } + + FILE *file = fopen(filename, "rb"); + if (!file) { + error_noexit("Cannot open LUT"); + return 0; + } + + png_init_io(png, file); + + // Read metadata + png_read_info(png, info); + uint32_t width = png_get_image_width(png, info); + uint32_t height = png_get_image_height(png, info); + png_byte color_type = png_get_color_type(png, info); + png_byte bit_depth = png_get_bit_depth(png, info); + + if (width != 256 && height != 256) { + error_noexit("LUT must be 256x256"); + return 0; + } + if (bit_depth != 8) { + error_noexit("LUT must be 8 bit"); + return 0; + } + if (color_type != PNG_COLOR_TYPE_RGB) { + error_noexit("LUT must be RGB"); + return 0; + } + + for (uint32_t i = 0; i < height; i++) { + png_read_row(png, (png_bytep)&out[i*width], NULL); + } + + png_read_end(png, info); + png_destroy_read_struct(&png, &info, NULL); + fclose(file); + return 1; +} diff --git a/aptdec-cli/pngio.h b/aptdec-cli/pngio.h new file mode 100644 index 0000000..e71d632 --- /dev/null +++ b/aptdec-cli/pngio.h @@ -0,0 +1,41 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef APTDEC_CLI_PNGIO_H_ +#define APTDEC_CLI_PNGIO_H_ + +#include +#include + +typedef struct { + png_structp png; + png_infop info; + FILE *file; + apt_region_t region; +} writer_t; + +writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height, int color, char *channel); +void writer_free(writer_t *png); + +void writer_write_image(writer_t *png, const apt_image_t *img); +void writer_write_image_gradient(writer_t *png, const apt_image_t *img, const uint32_t *gradient); +void writer_write_image_lut(writer_t *png, const apt_image_t *img, const png_colorp lut); + +int read_lut(const char *filename, png_colorp out); + +#endif diff --git a/src/util.c b/aptdec-cli/util.c similarity index 83% rename from src/util.c rename to aptdec-cli/util.c index 612267a..64a3f32 100644 --- a/src/util.c +++ b/aptdec-cli/util.c @@ -1,6 +1,6 @@ /* * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ #include "util.h" +#include #include #include @@ -28,10 +29,12 @@ void error_noexit(const char *text) { fprintf(stderr, "\033[31mError: %s\033[0m\n", text); #endif } + void error(const char *text) { error_noexit(text); exit(1); } + void warning(const char *text) { #ifdef _WIN32 fprintf(stderr, "Warning: %s\r\n", text); @@ -40,10 +43,12 @@ void warning(const char *text) { #endif } -float clamp(float x, float hi, float lo) { +int clamp_int(int x, int lo, int hi) { if (x > hi) return hi; if (x < lo) return lo; return x; } -float clamp_half(float x, float hi) { return clamp(x, hi, -hi); } +int get_version(char *str) { + return sprintf(str, "aptdec-cli %s using libaptdec %s", VERSION, aptdec_get_version()); +} diff --git a/src/util.h b/aptdec-cli/util.h similarity index 68% rename from src/util.h rename to aptdec-cli/util.h index 7fd01ec..c8ab688 100644 --- a/src/util.h +++ b/aptdec-cli/util.h @@ -1,6 +1,6 @@ /* * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,19 +16,17 @@ * along with this program. If not, see . */ -#include -#define M_PIf 3.14159265358979323846f -#define M_TAUf (M_PIf * 2.0f) +#ifndef APTDEC_CLI_UTIL_H_ +#define APTDEC_CLI_UTIL_H_ -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#include -#ifndef UTIL_H -#define UTIL_H -float clamp(float x, float hi, float lo); -float clamp_half(float x, float hi); - -void error(const char *text); void error_noexit(const char *text); +__attribute__((noreturn)) void error(const char *text); void warning(const char *text); + +int clamp_int(int x, int lo, int hi); + +int get_version(char *str); + #endif diff --git a/build_windows.bat b/build_windows.bat index b51f2a2..259beaa 100644 --- a/build_windows.bat +++ b/build_windows.bat @@ -2,7 +2,7 @@ REM Build using Visual Studio 2019 on Windows REM Additional tools needed: git, cmake and ninja REM Build zlib -git clone https://github.com/madler/zlib +git clone -b v1.2.13 https://github.com/madler/zlib cd zlib mkdir build cd build @@ -11,7 +11,7 @@ ninja install cd ../../ REM Build libpng -git clone https://github.com/glennrp/libpng +git clone -b v1.6.39 https://github.com/glennrp/libpng cd libpng mkdir build cd build @@ -20,7 +20,7 @@ ninja install cd ../.. REM Build libsndfile - Could build Vorbis, FLAC and Opus first for extra support -git clone https://github.com/libsndfile/libsndfile +git clone -b 1.1.0 https://github.com/libsndfile/libsndfile cd libsndfile mkdir build cd build diff --git a/build_windows.sh b/build_windows.sh index 4cb578a..5d9558f 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Cross compile for Windows from Linux TEMP_PATH="$(pwd)/winpath" @@ -39,7 +39,6 @@ cp "libsndfile-1.0.29-win64/bin/sndfile.dll" $TEMP_PATH/bin/sndfile.dll cp "libsndfile-1.0.29-win64/include/sndfile.h" $TEMP_PATH/include/sndfile.h cp "libsndfile-1.0.29-win64/lib/sndfile.lib" $TEMP_PATH/lib/sndfile.lib - # Copy DLL's into root for CPack cp $TEMP_PATH/bin/*.dll ../ diff --git a/cmake/FindLibSndFile.cmake b/cmake/FindLibSndFile.cmake deleted file mode 100644 index 6b381b1..0000000 --- a/cmake/FindLibSndFile.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# Find libsndfile -FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h) - -SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile) -FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH) - -IF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY) - SET(LIBSNDFILE_FOUND TRUE) -ENDIF(LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY) - -IF(LIBSNDFILE_FOUND) - IF(NOT LibSndFile_FIND_QUIETLY) - MESSAGE(STATUS "Found LibSndFile: ${LIBSNDFILE_LIBRARY}") - ENDIF(NOT LibSndFile_FIND_QUIETLY) -ELSE(LIBSNDFILE_FOUND) - IF(LibSndFile_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find sndfile") - ENDIF(LibSndFile_FIND_REQUIRED) -ENDIF(LIBSNDFILE_FOUND) diff --git a/src/algebra.c b/libaptdec/algebra.c similarity index 56% rename from src/algebra.c rename to libaptdec/algebra.c index bc7b9f6..e922a1e 100644 --- a/src/algebra.c +++ b/libaptdec/algebra.c @@ -1,6 +1,6 @@ /* * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +18,7 @@ #include "algebra.h" +#include #include // Find the best linear equation to estimate the value of the @@ -51,6 +52,67 @@ linear_t linear_regression(const float *independent, const float *dependent, siz return (linear_t){a, b}; } -float linear_calc(float x, linear_t line) { return x * line.a + line.b; } +float standard_deviation(const float *data, size_t len) { + float mean = 0.0f; + for (size_t i = 0; i < len; i++) { + mean += data[i]; + } + mean /= (float)len; + + float deviation_mean = 0.0f; + for (size_t i = 0; i < len; i++) { + float deviation = data[i] - mean; + deviation_mean += deviation * deviation; + } + + return sqrtf(deviation_mean / (float)len); +} + +float sumf(const float *x, size_t len) { + float sum = 0.0f; + for (size_t i = 0; i < len; i++) { + sum += x[i]; + } + return sum; +} + +float meanf(const float *x, size_t len) { + return sumf(x, len) / (float)len; +} + +void normalizef(float *x, size_t len) { + float sum = sumf(x, len); + + for (size_t i = 0; i < len; i++) { + x[i] /= sum; + } +} + +static int sort_func(const void *a, const void *b) { + return *(float *)b > *(float *)a ? 1 : -1; +} + +float medianf(float *data, size_t len) { + qsort(data, len, sizeof(float), sort_func); -float quadratic_calc(float x, quadratic_t quadratic) { return x * x * quadratic.a + x * quadratic.b + quadratic.c; } + if (len % 2 == 0) { + return (data[len/2] + data[len/2 - 1]) / 2.0f; + } else { + return data[len/2]; + } +} + +float linear_calc(float x, linear_t line) { + return x * line.a + line.b; +} + +float quadratic_calc(float x, quadratic_t quadratic) { + return x*x * quadratic.a + x * quadratic.b + quadratic.c; +} + +float sincf(float x) { + if (x == 0.0f) { + return 1.0f; + } + return sinf(M_PIf * x) / (M_PIf * x); +} diff --git a/src/algebra.h b/libaptdec/algebra.h similarity index 71% rename from src/algebra.h rename to libaptdec/algebra.h index 08b46af..c7f654d 100644 --- a/src/algebra.h +++ b/libaptdec/algebra.h @@ -1,6 +1,6 @@ /* * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,10 +16,13 @@ * along with this program. If not, see . */ -#ifndef APTDEC_ALGEBRA_H -#define APTDEC_ALGEBRA_H +#ifndef LIBAPTDEC_ALGEBRA_H_ +#define LIBAPTDEC_ALGEBRA_H_ #include +#define M_PIf 3.14159265358979323846f +#define M_TAUf (M_PIf * 2.0f) + // A linear equation in the form of y(x) = ax + b typedef struct { float a, b; @@ -31,8 +34,16 @@ typedef struct { } quadratic_t; linear_t linear_regression(const float *independent, const float *dependent, size_t len); +float standard_deviation(const float *data, size_t len); +float sumf(const float *x, size_t len); +float meanf(const float *x, size_t len); +void normalizef(float *x, size_t len); + +// NOTE: Modifies input array +float medianf(float *data, size_t len); float linear_calc(float x, linear_t line); float quadratic_calc(float x, quadratic_t quadratic); +float sincf(float x); #endif diff --git a/libaptdec/calibration.c b/libaptdec/calibration.c new file mode 100644 index 0000000..0bec609 --- /dev/null +++ b/libaptdec/calibration.c @@ -0,0 +1,121 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "calibration.h" + +#include "util.h" + +// clang-format off +const calibration_t calibration[3] = { + { + .name = "NOAA-15", + .prt = { + { 1.36328e-06f, 0.051045f, 276.60157f }, // PRT 1 + { 1.47266e-06f, 0.050909f, 276.62531f }, // PRT 2 + { 1.47656e-06f, 0.050907f, 276.67413f }, // PRT 3 + { 1.47656e-06f, 0.050966f, 276.59258f } // PRT 4 + }, + .visible = { + { + .low = { 0.0568f, -2.1874f }, + .high = { 0.1633f, -54.9928f }, + .cutoff = 496.0f + }, { + .low = { 0.0596f, -2.4096f }, + .high = { 0.1629f, -55.2436f }, + .cutoff = 511.0f + } + }, + .rad = { + { 925.4075f, 0.337810f, 0.998719f }, // Channel 4 + { 839.8979f, 0.304558f, 0.999024f }, // Channel 5 + { 2695.9743f, 1.621256f, 0.998015f } // Channel 3B + }, + .cor = { + { -4.50f, { 0.0004524f, -0.0932f, 4.76f } }, // Channel 4 + { -3.61f, { 0.0002811f, -0.0659f, 3.83f } }, // Channel 5 + { 0.0f, { 0.0f, 0.0f , 0.0f } } // Channel 3B + } + }, { + .name = "NOAA-18", + .prt = { + { 1.657e-06f, 0.05090f, 276.601f }, // PRT 1 + { 1.482e-06f, 0.05101f, 276.683f }, // PRT 2 + { 1.313e-06f, 0.05117f, 276.565f }, // PRT 3 + { 1.484e-06f, 0.05103f, 276.615f } // PRT 4 + }, + .visible = { + { + .low = { 0.06174f, -2.434f }, + .high = { 0.1841f, -63.31f }, + .cutoff = 501.54f + }, { + .low = { 0.07514f, -2.960f }, + .high = { 0.2254f, -78.55f }, + .cutoff = 500.40f + } + }, + .rad = { + { 928.1460f, 0.436645f, 0.998607f }, // Channel 4 + { 833.2532f, 0.253179f, 0.999057f }, // Channel 5 + { 2659.7952f, 1.698704f, 0.996960f } // Channel 3B + }, + .cor = { + { -5.53f, { 0.00052337f, -0.11069f, 5.82f } }, // Channel 4 + { -2.22f, { 0.00017715f, -0.04360f, 2.67f } }, // Channel 5 + { 0.0f, { 0.0f, 0.0f, 0.0f } } // Channel 3B + } + }, { + .name = "NOAA-19", + .prt = { + { 1.405783e-06f, 0.051111f, 276.6067f }, // PRT 1 + { 1.496037e-06f, 0.051090f, 276.6119f }, // PRT 2 + { 1.496990e-06f, 0.051033f, 276.6311f }, // PRT 3 + { 1.493110e-06f, 0.051058f, 276.6268f } // PRT 4 + }, + .visible = { + { + .low = { 0.05555f, -2.159f }, + .high = { 0.1639f, -56.33f }, + .cutoff = 496.43f + }, { + .low = { 0.06614f, -2.565f }, + .high = { 0.1970f, -68.01f }, + .cutoff = 500.37f + } + }, + .rad = { + { 928.9f, 0.53959f, 0.998534f }, // Channel 4 + { 831.9f, 0.36064f, 0.998913f }, // Channel 5 + { 2670.0f, 1.67396f, 0.997364f } // Channel 3B + }, + .cor = { + { -5.49f, { 0.00054668f, -0.11187f, 5.70f } }, // Channel 4 + { -3.39f, { 0.00024985f, -0.05991f, 3.58f } }, // Channel 5 + { 0.0f, { 0.0f, 0.0f, 0.0f } } // Channel 3B + } + } +}; + +calibration_t get_calibration(apt_satellite_t satid) { + switch (satid) { + case NOAA15: return calibration[0]; + case NOAA18: return calibration[1]; + default: return calibration[2]; + } +} diff --git a/src/calibration.h b/libaptdec/calibration.h similarity index 87% rename from src/calibration.h rename to libaptdec/calibration.h index 5580dd6..46313e2 100644 --- a/src/calibration.h +++ b/libaptdec/calibration.h @@ -1,6 +1,6 @@ /* * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,9 +16,11 @@ * along with this program. If not, see . */ -#ifndef APTDEC_CALIBRATION_H -#define APTDEC_CALIBRATION_H +#ifndef LIBAPTDEC_CALIBRATION_H_ +#define LIBAPTDEC_CALIBRATION_H_ + #include "algebra.h" +#include typedef struct { char *name; @@ -50,6 +52,6 @@ static const float C1 = 1.1910427e-5f; // Second radiation constant (cm-K) static const float C2 = 1.4387752f; -calibration_t get_calibration(int satid); +calibration_t get_calibration(apt_satellite_t satid); #endif diff --git a/libaptdec/color.c b/libaptdec/color.c new file mode 100644 index 0000000..43bacb2 --- /dev/null +++ b/libaptdec/color.c @@ -0,0 +1,94 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include "util.h" + +#define MCOMPOSITE(m1, a1, m2, a2) (m1 * a1 + m2 * a2 * (1 - a1)) + +// clang-format off + +apt_rgb_t apt_gradient(const uint32_t *gradient, uint8_t val) { + return (apt_rgb_t) { + (gradient[val] & 0x00FF0000) >> 16, + (gradient[val] & 0x0000FF00) >> 8, + (gradient[val] & 0x000000FF) + }; +} + +apt_rgb_t apt_composite_rgb(apt_rgb_t top, float top_alpha, apt_rgb_t bottom, float bottom_alpha) { + return (apt_rgb_t) { + MCOMPOSITE(top.r, top_alpha, bottom.r, bottom_alpha), + MCOMPOSITE(top.g, top_alpha, bottom.g, bottom_alpha), + MCOMPOSITE(top.b, top_alpha, bottom.b, bottom_alpha) + }; +} + +// Taken from WXtoImg +const uint32_t temperature_gradient[256] = { + 0x45008F, 0x460091, 0x470092, 0x480094, 0x490096, 0x4A0098, 0x4B009B, + 0x4D009D, 0x4E00A0, 0x5000A2, 0x5100A5, 0x5200A7, 0x5400AA, 0x5600AE, + 0x5700B1, 0x5800B4, 0x5A00B7, 0x5C00BA, 0x5E00BD, 0x5F00C0, 0x6100C4, + 0x6400C8, 0x6600CB, 0x6800CE, 0x6900D1, 0x6800D4, 0x6500D7, 0x6300DA, + 0x6100DD, 0x5D00E1, 0x5B00E4, 0x5900E6, 0x5600E9, 0x5300EB, 0x5000EE, + 0x4D00F0, 0x4900F3, 0x4700FC, 0x4300FA, 0x3100BF, 0x200089, 0x200092, + 0x1E0095, 0x1B0097, 0x19009A, 0x17009C, 0x15009E, 0x1200A0, 0x0F00A3, + 0x0F02A5, 0x0E06A8, 0x0E0AAB, 0x0E0DAD, 0x0E11B1, 0x0D15B4, 0x0D18B7, + 0x0D1CBA, 0x0B21BD, 0x0A25C0, 0x0A29C3, 0x092DC6, 0x0833CA, 0x0736CD, + 0x073BD0, 0x0741D3, 0x0545D6, 0x044BD9, 0x0450DC, 0x0355DE, 0x025DE2, + 0x0161E5, 0x0066E7, 0x006CEA, 0x0072EC, 0x0078EE, 0x007DF0, 0x0082F3, + 0x008DFC, 0x0090FA, 0x0071BF, 0x005489, 0x005C91, 0x006194, 0x006496, + 0x006897, 0x006D99, 0x00719B, 0x00759D, 0x00799F, 0x007EA0, 0x0082A2, + 0x0087A4, 0x008CA6, 0x0092AA, 0x0096AC, 0x009CAE, 0x00A2B1, 0x00A6B3, + 0x00AAB5, 0x00ADB7, 0x00B1BA, 0x00B6BE, 0x00BAC0, 0x00BEC2, 0x00C2C5, + 0x00C6C6, 0x00CAC9, 0x00CCCA, 0x00CFCB, 0x00D2CC, 0x00D4CC, 0x00D6CC, + 0x00D9CB, 0x00DBCB, 0x00DECB, 0x00E0CB, 0x00E2CC, 0x00EAD2, 0x00EACF, + 0x00B9A4, 0x008E7A, 0x01947C, 0x049779, 0x079975, 0x099B71, 0x0D9D6B, + 0x109F67, 0x12A163, 0x15A35F, 0x17A559, 0x1AA855, 0x1DAA50, 0x20AC4B, + 0x24AF45, 0x28B241, 0x2BB53B, 0x2EB835, 0x31BA30, 0x34BD2B, 0x39BF24, + 0x3FC117, 0x49C508, 0x4FC801, 0x4FCA00, 0x4ECD00, 0x4ECF00, 0x4FD200, + 0x54D500, 0x5DD800, 0x68DB00, 0x6EDD00, 0x74DF00, 0x7AE200, 0x7FE400, + 0x85E700, 0x8BE900, 0x8FEB00, 0x9BF300, 0x9EF200, 0x7EBB00, 0x608A00, + 0x689200, 0x6D9500, 0x719600, 0x759800, 0x7B9A00, 0x7F9D00, 0x839F00, + 0x87A100, 0x8CA200, 0x8FA500, 0x92A700, 0x96A900, 0x9AAD00, 0x9DB000, + 0xA1B200, 0xA5B500, 0xA9B700, 0xADBA00, 0xB2BD00, 0xB6BF00, 0xBBC300, + 0xBFC600, 0xC3C800, 0xC8CB00, 0xCCCE00, 0xD0D100, 0xD3D200, 0xD5D400, + 0xD9D400, 0xDCD400, 0xDED500, 0xE1D500, 0xE3D500, 0xE6D400, 0xE8D100, + 0xEACE00, 0xF2CF00, 0xF2CA00, 0xBB9900, 0x8A6E00, 0x927200, 0x957200, + 0x977100, 0x9A7000, 0x9C6E00, 0x9E6D00, 0xA06B00, 0xA36A00, 0xA56800, + 0xA86700, 0xAB6600, 0xAE6500, 0xB26300, 0xB46100, 0xB75F00, 0xBA5D00, + 0xBD5C00, 0xC05900, 0xC35700, 0xC65400, 0xCA5000, 0xCD4D00, 0xD04A00, + 0xD34700, 0xD64300, 0xD94000, 0xDC3D00, 0xDE3900, 0xE23300, 0xE52F00, + 0xE72C00, 0xEA2800, 0xEC2300, 0xEF1F00, 0xF11A00, 0xF31400, 0xFB0F00, + 0xFA0D00, 0xC10500, 0x8E0000, 0x970000, 0x9B0000, 0x9E0000, 0xA10000, + 0xA50000, 0xA90000, 0xAD0000, 0xB10000, 0xB60000, 0xBA0000, 0xBD0000, + 0xC20000, 0xC80000, 0xCC0000, 0xCC0000 +}; + +// Taken from WXtoImg +const uint32_t precipitation_gradient[58] = { + 0x088941, 0x00C544, 0x00D12C, 0x00E31C, 0x00F906, 0x14FF00, 0x3EFF00, + 0x5DFF00, 0x80FF00, 0xABFF00, 0xCDFE00, 0xF8FF00, 0xFFE600, 0xFFB800, + 0xFF9800, 0xFF7500, 0xFF4900, 0xFE2600, 0xFF0400, 0xDF0000, 0xA80000, + 0x870000, 0x5A0000, 0x390000, 0x110000, 0x0E1010, 0x232222, 0x333333, + 0x414141, 0x535353, 0x606060, 0x6E6E6E, 0x808080, 0x8E8E8E, 0xA0A0A0, + 0xAEAEAE, 0xC0C0C0, 0xCECECE, 0xDCDCDC, 0xEFEFEF, 0xFAFAFA, 0xFFFFFF, + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, + 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, + 0xFFFFFF, 0xFFFFFF +}; diff --git a/libaptdec/dsp.c b/libaptdec/dsp.c new file mode 100644 index 0000000..3c5f486 --- /dev/null +++ b/libaptdec/dsp.c @@ -0,0 +1,237 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +#include "filter.h" +#include "util.h" +#include "algebra.h" + +#define BUFFER_SIZE 16384 +#define LOW_PASS_SIZE 101 + +#define CARRIER_FREQ 2400.0f +#define MAX_CARRIER_OFFSET 10.0f + +typedef struct { + float alpha; + float beta; + float min_freq; + float max_freq; + + float freq; + float phase; +} pll_t; + +typedef struct { + float *ring_buffer; + size_t ring_size; + + float *taps; + size_t ntaps; +} fir_t; + +struct aptdec_t { + float sample_rate; + float sync_frequency; + + pll_t *pll; + fir_t *hilbert; + + float low_pass[LOW_PASS_SIZE]; +}; + +char *aptdec_get_version(void) { + return VERSION; +} + +fir_t *fir_init(size_t max_size, size_t ntaps) { + fir_t *fir = (fir_t *)malloc(sizeof(fir_t)); + fir->ntaps = ntaps; + fir->ring_size = max_size + ntaps; + fir->taps = (float *)malloc(ntaps * sizeof(float)); + fir->ring_buffer = (float *)malloc((max_size + ntaps) * sizeof(float)); + return fir; +} + +void fir_free(fir_t *fir) { + free(fir->ring_buffer); + free(fir->taps); + free(fir); +} + +pll_t *pll_init(float alpha, float beta, float min_freq, float max_freq, float sample_rate) { + pll_t *pll = (pll_t *)malloc(sizeof(pll_t)); + pll->alpha = alpha; + pll->beta = beta; + pll->min_freq = M_TAUf * min_freq / sample_rate; + pll->max_freq = M_TAUf * max_freq / sample_rate; + pll->phase = 0.0f; + pll->freq = 0.0f; + return pll; +} + +aptdec_t *aptdec_init(float sample_rate) { + if (sample_rate > 96000 || sample_rate < (CARRIER_FREQ + APT_IMG_WIDTH) * 2.0f) { + return NULL; + } + + aptdec_t *apt = (aptdec_t *)malloc(sizeof(aptdec_t)); + apt->sample_rate = sample_rate; + apt->sync_frequency = 1.0f; + + // PLL configuration + // https://www.trondeau.com/blog/2011/8/13/control-loop-gain-values.html + float damp = 0.7f; + float bw = 0.005f; + float alpha = (4.0f * damp * bw) / (1.0f + 2.0f * damp * bw + bw * bw); + float beta = (4.0f * bw * bw) / (1.0f + 2.0f * damp * bw + bw * bw); + apt->pll = pll_init(alpha, beta, CARRIER_FREQ-MAX_CARRIER_OFFSET, CARRIER_FREQ+MAX_CARRIER_OFFSET, sample_rate); + if (apt->pll == NULL) { + free(apt); + return NULL; + } + + // Hilbert transform + apt->hilbert = fir_init(BUFFER_SIZE, 31); + if (apt->hilbert == NULL) { + free(apt->pll); + free(apt); + return NULL; + } + design_hilbert(apt->hilbert->taps, apt->hilbert->ntaps); + + design_low_pass(apt->low_pass, apt->sample_rate, (2080.0f + CARRIER_FREQ) / 2.0f, LOW_PASS_SIZE); + + return apt; +} + +void aptdec_free(aptdec_t *apt) { + fir_free(apt->hilbert); + free(apt->pll); + free(apt); +} + +static complexf_t pll_work(pll_t *pll, complexf_t in) { + // Internal oscillator (90deg offset) + complexf_t osc = complex_build(cosf(pll->phase), -sinf(pll->phase)); + in = complex_multiply(in, osc); + + // Error detector + float error = cargf(in); + + // Loop filter (single pole IIR) + pll->freq += pll->beta * error; + pll->freq = clamp(pll->freq, pll->min_freq, pll->max_freq); + pll->phase += pll->freq + (pll->alpha * error); + pll->phase = remainderf(pll->phase, M_TAUf); + + return in; +} + +static int am_demod(aptdec_t *apt, float *out, size_t count, aptdec_callback_t callback, void *context) { + size_t read = callback(&apt->hilbert->ring_buffer[apt->hilbert->ntaps], count, context); + + for (size_t i = 0; i < read; i++) { + complexf_t sample = hilbert_transform(&apt->hilbert->ring_buffer[i], apt->hilbert->taps, apt->hilbert->ntaps); + out[i] = crealf(pll_work(apt->pll, sample)); + } + + memcpy(apt->hilbert->ring_buffer, &apt->hilbert->ring_buffer[read], apt->hilbert->ntaps*sizeof(float)); + + return read; +} + +static int get_pixels(aptdec_t *apt, float *out, size_t count, aptdec_callback_t callback, void *context) { + static float buffer[BUFFER_SIZE]; + static size_t n = BUFFER_SIZE; + static float offset = 0.0; + + float ratio = apt->sample_rate / (4160.0f * apt->sync_frequency); + + for (size_t i = 0; i < count; i++) { + // Get more samples if there are less than `LOW_PASS_SIZE` available + if (n + LOW_PASS_SIZE > BUFFER_SIZE) { + memcpy(buffer, &buffer[n], (BUFFER_SIZE-n) * sizeof(float)); + + size_t read = am_demod(apt, &buffer[BUFFER_SIZE-n], n, callback, context); + if (read != n) { + return i; + } + n = 0; + } + + out[i] = interpolating_convolve(&buffer[n], apt->low_pass, LOW_PASS_SIZE, offset); + + // Do not question the sacred code + int shift = ceilf(ratio - offset); + offset = shift + offset - ratio; + n += shift; + } + + return count; +} + +const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, + 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; +#define SYNC_SIZE (sizeof(sync_pattern)/sizeof(sync_pattern[0])) + +// Get an entire row of pixels, aligned with sync markers +int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *context) { + static float pixels[APT_IMG_WIDTH + SYNC_SIZE + 2]; + + // Wrap the circular buffer + memcpy(pixels, &pixels[APT_IMG_WIDTH], (SYNC_SIZE + 2) * sizeof(float)); + // Get a lines worth (APT_IMG_WIDTH) of samples + if (get_pixels(apt, &pixels[SYNC_SIZE + 2], APT_IMG_WIDTH, callback, context) != APT_IMG_WIDTH) { + return 0; + } + + // Error detector + float left = FLT_MIN; + float middle = FLT_MIN; + float right = FLT_MIN; + size_t phase = 0; + + for (size_t i = 0; i < APT_IMG_WIDTH; i++) { + float _left = convolve(&pixels[i + 0], sync_pattern, SYNC_SIZE); + float _middle = convolve(&pixels[i + 1], sync_pattern, SYNC_SIZE); + float _right = convolve(&pixels[i + 2], sync_pattern, SYNC_SIZE); + if (_middle > middle) { + left = _left; + middle = _middle; + right = _right; + phase = i + 1; + } + } + + // Frequency + float bias = (left / middle) - (right / middle); + apt->sync_frequency = 1.0f + bias / APT_IMG_WIDTH / 2.0f; + + // Phase + memcpy(&row[APT_IMG_WIDTH], &pixels[phase], (APT_IMG_WIDTH - phase) * sizeof(float)); + memcpy(&row[APT_IMG_WIDTH - phase], pixels, phase * sizeof(float)); + + return 1; +} diff --git a/libaptdec/effects.c b/libaptdec/effects.c new file mode 100644 index 0000000..f8eff14 --- /dev/null +++ b/libaptdec/effects.c @@ -0,0 +1,175 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include "algebra.h" +#include "util.h" +#include "filter.h" + +void apt_equalize(apt_image_t *img, apt_region_t region) { + // Plot histogram + size_t histogram[256] = {0}; + for (size_t y = 0; y < img->rows; y++) { + for (size_t x = 0; x < region.width; x++) { + histogram[img->data[y * APT_IMG_WIDTH + x + region.offset]]++; + } + } + + // Calculate cumulative frequency + size_t sum = 0, cf[256] = {0}; + for (int i = 0; i < 256; i++) { + sum += histogram[i]; + cf[i] = sum; + } + + // Apply histogram + int area = img->rows * region.width; + for (size_t y = 0; y < img->rows; y++) { + for (size_t x = 0; x < region.width; x++) { + int k = (int)img->data[y * APT_IMG_WIDTH + x + region.offset]; + img->data[y * APT_IMG_WIDTH + x + region.offset] = (255.0f / area) * cf[k]; + } + } +} + +// Brightness calibrate, including telemetry +static void image_apply_linear(uint8_t *data, int rows, int offset, int width, linear_t regr) { + for (int y = 0; y < rows; y++) { + for (int x = 0; x < width; x++) { + float pv = linear_calc(data[y * APT_IMG_WIDTH + x + offset], regr); + data[y * APT_IMG_WIDTH + x + offset] = clamp_int(roundf(pv), 0, 255); + } + } +} + +void apt_stretch(apt_image_t *img, apt_region_t region) { + // Plot histogram + size_t histogram[256] = { 0 }; + for (size_t y = 0; y < img->rows; y++) { + for (size_t x = 0; x < region.width; x++) { + histogram[img->data[y*APT_IMG_WIDTH + x + region.offset]]++; + } + } + + // Calculate cumulative frequency + size_t sum = 0; + size_t cf[256] = { 0 }; + for (size_t i = 0; i < 256; i++) { + sum += histogram[i]; + cf[i] = sum; + } + + // Find min/max points (1st percentile) + int min = -1, max = -1; + for (size_t i = 0; i < 256; i++) { + if ((float)cf[i] / (float)sum < 0.01f && min == -1) { + min = i; + } + if ((float)cf[i] / (float)sum > 0.99f && max == -1) { + max = i; + break; + } + } + + float a = 255.0f / (max - min); + float b = a * -min; + image_apply_linear(img->data, img->rows, region.offset, region.width, (linear_t){a, b}); +} + + + +// Median denoise (with deviation threshold) +void apt_denoise(apt_image_t *img, apt_region_t region) { + for (size_t y = 1; y < img->rows - 1; y++) { + for (size_t x = 1; x < region.width - 1; x++) { + float pixels[9]; + int pixeln = 0; + for (int y2 = -1; y2 < 2; y2++) { + for (int x2 = -1; x2 < 2; x2++) { + pixels[pixeln++] = img->data[(y + y2) * APT_IMG_WIDTH + (x + region.offset) + x2]; + } + } + + if (standard_deviation(pixels, 9) > 15) { + img->data[y * APT_IMG_WIDTH + x + region.offset] = medianf(pixels, 9); + } + } + } +} + +// Flips a channel, for northbound passes +void apt_flip(apt_image_t *img, apt_region_t region) { + for (size_t y = 1; y < img->rows; y++) { + for (int x = 1; x < ceil(region.width / 2.0f); x++) { + // Flip top-left & bottom-right + swap_uint8( + &img->data[(img->rows - y) * APT_IMG_WIDTH + region.offset + x], + &img->data[y * APT_IMG_WIDTH + region.offset + (region.width - x)] + ); + } + } +} + +// Calculate crop to remove noise from the start and end of an image +#define NOISE_THRESH 2600.0 + +#include "filter.h" + +int apt_crop(apt_image_t *img) { + const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, + 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; + + float spc_rows[img->rows]; + int startCrop = 0; + int endCrop = img->rows; + + for (size_t y = 0; y < img->rows; y++) { + float temp[39]; + for (size_t i = 0; i < 39; i++) { + temp[i] = img->data[y * APT_IMG_WIDTH + i]; + } + + spc_rows[y] = convolve(temp, &sync_pattern[0], 39); + } + + // Find ends + for (size_t y = 0; y < img->rows - 1; y++) { + if (spc_rows[y] > NOISE_THRESH) { + endCrop = y; + } + } + for (size_t y = img->rows; y > 0; y--) { + if (spc_rows[y] > NOISE_THRESH) { + startCrop = y; + } + } + + printf("Crop rows: %i -> %i\n", startCrop, endCrop); + + // Ignore the noisy rows at the end + img->rows = (endCrop - startCrop); + + // Remove the noisy rows at start + memmove(img->data, &img->data[startCrop * APT_IMG_WIDTH], img->rows * APT_IMG_WIDTH * sizeof(float)); + + return startCrop; +} diff --git a/libaptdec/filter.c b/libaptdec/filter.c new file mode 100644 index 0000000..e45fbf8 --- /dev/null +++ b/libaptdec/filter.c @@ -0,0 +1,109 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "filter.h" + +#include +// SSE2 intrinsics +#ifdef __x86_64__ +#include +#endif + +#include "algebra.h" + +// Blackman window +// https://en.wikipedia.org/wiki/Window_function#Blackman_window +static float blackman(float n, size_t ntaps) { + n = (M_PIf * n) / (float)(ntaps - 1); + return 0.42f - 0.5f*cosf(2 * n) + 0.08f*cosf(4 * n); +} + +// Sinc low pass with blackman window. +// https://tomroelandts.com/articles/how-to-create-a-simple-low-pass-filter +void design_low_pass(float *taps, float samp_rate, float cutoff, size_t ntaps) { + for (size_t i = 0; i < ntaps; i++) { + int x = i - ntaps/2; + taps[i] = sincf(2.0f * cutoff/samp_rate * (float)x); + taps[i] *= blackman(i, ntaps); + } + + // Achieve unity gain + normalizef(taps, ntaps); +} + +// Hilbert filter with blackman window. +// https://www.recordingblogs.com/wiki/hilbert-transform +void design_hilbert(float *taps, size_t ntaps) { + for (size_t i = 0; i < ntaps; i++) { + int x = i - ntaps/2; + + if (x % 2 == 0) { + taps[i] = 0.0f; + } else { + taps[i] = 2.0f / (M_PIf * (float)x); + taps[i] *= blackman(i, ntaps); + } + } + + // Achieve unity gain + normalizef(taps, ntaps); +} + +float convolve(const float *in, const float *taps, size_t len) { +#ifdef __SSE2__ + __m128 sum = _mm_setzero_ps(); + + size_t i; + for (i = 0; i < len - 3; i += 4) { + __m128 _taps = _mm_loadu_ps(&taps[i]); + __m128 _in = _mm_loadu_ps(&in[i]); + sum = _mm_add_ps(sum, _mm_mul_ps(_taps, _in)); + } + + float residual = 0.0f; + for (; i < len; i++) { + residual += in[i] * taps[i]; + } + + __attribute__((aligned(16))) float _sum[4]; + _mm_store_ps(_sum, sum); + return _sum[0] + _sum[1] + _sum[2] + _sum[3] + residual; +#else + float sum = 0.0f; + for (size_t i = 0; i < len; i++) { + sum += in[i] * taps[i]; + } + + return sum; +#endif +} + +complexf_t hilbert_transform(const float *in, const float *taps, size_t len) { + return complex_build(in[len / 2], convolve(in, taps, len)); +} + +float interpolating_convolve(const float *in, const float *taps, size_t len, float offset) { + float _taps[len]; + + for (size_t i = 0; i < len; i++) { + float next = (i == len-1) ? 0.0f : taps[i+1]; + _taps[i] = taps[i]*(1.0f-offset) + next*offset; + } + + return convolve(in, _taps, len); +} diff --git a/src/filter.h b/libaptdec/filter.h similarity index 66% rename from src/filter.h rename to libaptdec/filter.h index 124a59b..d80a7df 100644 --- a/src/filter.h +++ b/libaptdec/filter.h @@ -1,6 +1,6 @@ /* * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,15 +16,27 @@ * along with this program. If not, see . */ +#ifndef LIBAPTDEC_FILTER_H_ +#define LIBAPTDEC_FILTER_H_ + #include #include #ifdef _MSC_VER typedef _Fcomplex complexf_t; +#define complex_build(real, imag) _FCbuild(real, imag) +#define complex_multiply(a, b) _FCmulcc(a, b) #else typedef complex float complexf_t; +#define complex_build(real, imag) ((real) + (imag)*I) +#define complex_multiply(a, b) ((a) * (b)) #endif +void design_low_pass(float *taps, float samp_rate, float cutoff, size_t ntaps); +void design_hilbert(float *taps, size_t ntaps); + float convolve(const float *in, const float *taps, size_t len); complexf_t hilbert_transform(const float *in, const float *taps, size_t len); -float interpolating_convolve(const float *in, const float *taps, size_t len, float offset, float delta); +float interpolating_convolve(const float *in, const float *taps, size_t len, float offset); + +#endif diff --git a/libaptdec/image.c b/libaptdec/image.c new file mode 100644 index 0000000..7093563 --- /dev/null +++ b/libaptdec/image.c @@ -0,0 +1,236 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +#include "algebra.h" +#include +#include "util.h" +#include "calibration.h" + +#define APT_COUNT_RATIO (1023.0f/255.0f) + +apt_image_t apt_image_clone(apt_image_t img) { + apt_image_t _img = img; + _img.data = (uint8_t *)malloc(APT_IMG_WIDTH * img.rows); + memcpy(_img.data, img.data, APT_IMG_WIDTH * img.rows); + return _img; +} + +static void decode_telemetry(const float *data, size_t rows, size_t offset, float *wedges) { + // Calculate row average + float telemetry_rows[rows]; + for (size_t y = 0; y < rows; y++) { + telemetry_rows[y] = meanf(&data[y*APT_IMG_WIDTH + offset + APT_CH_WIDTH], APT_TELEMETRY_WIDTH); + } + + // Calculate relative telemetry offset (via step detection, i.e. wedge 8 to 9) + size_t telemetry_offset = 0; + float max_difference = 0.0f; + for (size_t y = APT_WEDGE_HEIGHT; y <= rows - APT_WEDGE_HEIGHT; y++) { + float difference = sumf(&telemetry_rows[y - APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT) - sumf(&telemetry_rows[y], APT_WEDGE_HEIGHT); + + // Find the maximum difference + if (difference > max_difference) { + max_difference = difference; + telemetry_offset = (y + 64) % APT_FRAME_LEN; + } + } + + // Find the least noisy frame (via standard deviation) + float best_noise = FLT_MAX; + size_t best_frame = 0; + for (size_t y = telemetry_offset; y < rows; y += APT_FRAME_LEN) { + float noise = 0.0f; + for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { + noise += standard_deviation(&telemetry_rows[y + i*APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT); + } + + if (noise < best_noise) { + best_noise = noise; + best_frame = y; + } + } + + for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { + wedges[i] = meanf(&telemetry_rows[best_frame + i*APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT); + } +} + +static float average_spc(apt_image_t *img, size_t offset) { + float rows[img->rows]; + float average = 0.0f; + for (size_t y = 0; y < img->rows; y++) { + float row_average = 0.0f; + for (size_t x = 0; x < APT_SPC_WIDTH; x++) { + row_average += img->data[y*APT_IMG_WIDTH + offset - APT_SPC_WIDTH + x]; + } + row_average /= (float)APT_SPC_WIDTH; + + rows[y] = row_average; + average += row_average; + } + average /= (float)img->rows; + + float weighted_average = 0.0f; + size_t n = 0; + for (size_t y = 0; y < img->rows; y++) { + if (fabsf(rows[y] - average) < 50.0f) { + weighted_average += rows[y]; + n++; + } + } + + return weighted_average / (float)n; +} + +apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satellite, int *error) { + apt_image_t img; + img.rows = rows; + img.satellite = satellite; + + *error = 0; + if (rows < APTDEC_NORMALIZE_ROWS) { + *error = -1; + return img; + } + + // Decode and average wedges + float wedges[APT_FRAME_WEDGES]; + float wedges_cha[APT_FRAME_WEDGES]; + float wedges_chb[APT_FRAME_WEDGES]; + decode_telemetry(data, rows, APT_CHA_OFFSET, wedges_cha); + decode_telemetry(data, rows, APT_CHB_OFFSET, wedges_chb); + for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { + wedges[i] = (wedges_cha[i] + wedges_chb[i]) / 2.0f; + } + + // Calculate normalization + const float reference[9] = { 31, 63, 95, 127, 159, 191, 223, 255, 0 }; + linear_t normalization = linear_regression(wedges, reference, 9); + if (normalization.a < 0.0f) { + *error = -1; + return img; + } + + // Normalize telemetry + for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { + img.telemetry[0][i] = linear_calc(wedges_cha[i], normalization); + img.telemetry[1][i] = linear_calc(wedges_chb[i], normalization); + } + + // Decode channel ID wedges + img.ch[0] = roundf(img.telemetry[0][15] / 32.0f); + img.ch[1] = roundf(img.telemetry[1][15] / 32.0f); + if (img.ch[0] < 1 || img.ch[0] > 6) img.ch[0] = AVHRR_CHANNEL_UNKNOWN; + if (img.ch[1] < 1 || img.ch[1] > 6) img.ch[1] = AVHRR_CHANNEL_UNKNOWN; + + // Normalize and quantize image data + img.data = (uint8_t *)malloc(rows * APT_IMG_WIDTH); + for (size_t i = 0; i < rows * APT_IMG_WIDTH; i++) { + float count = linear_calc(data[i], normalization); + img.data[i] = clamp_int(roundf(count), 0, 255); + } + + // Get space brightness + img.space_view[0] = average_spc(&img, APT_CHA_OFFSET); + img.space_view[1] = average_spc(&img, APT_CHB_OFFSET); + + return img; +} + +static void make_thermal_lut(apt_image_t *img, avhrr_channel_t ch, int satellite, float *lut) { + ch -= 4; + const calibration_t calibration = get_calibration(satellite); + const float Ns = calibration.cor[ch].Ns; + const float Vc = calibration.rad[ch].vc; + const float A = calibration.rad[ch].A; + const float B = calibration.rad[ch].B; + + // Compute PRT temperature + float T[4]; + for (size_t n = 0; n < 4; n++) { + T[n] = quadratic_calc(img->telemetry[1][n + 9] * APT_COUNT_RATIO, calibration.prt[n]); + } + + float Tbb = meanf(T, 4); // Blackbody temperature + float Tbbstar = A + Tbb * B; // Effective blackbody temperature + + float Nbb = C1 * pow(Vc, 3) / (expf(C2 * Vc / Tbbstar) - 1.0f); // Blackbody radiance + + float Cs = img->space_view[1] * APT_COUNT_RATIO; + float Cb = img->telemetry[1][14] * APT_COUNT_RATIO; + + for (size_t i = 0; i < 256; i++) { + float Nl = Ns + (Nbb - Ns) * (Cs - i * APT_COUNT_RATIO) / (Cs - Cb); // Linear radiance estimate + float Nc = quadratic_calc(Nl, calibration.cor[ch].quadratic); // Non-linear correction + float Ne = Nl + Nc; // Corrected radiance + + float Testar = C2 * Vc / logf(C1 * powf(Vc, 3) / Ne + 1.0); // Equivalent black body temperature + float Te = (Testar - A) / B; // Temperature (kelvin) + + // Convert to celsius + lut[i] = Te - 273.15; + } +} + +int apt_calibrate_thermal(apt_image_t *img, apt_region_t region) { + if (img->ch[1] != AVHRR_CHANNEL_4 && img->ch[1] != AVHRR_CHANNEL_5 && img->ch[1] != AVHRR_CHANNEL_3B) { + return 1; + } + + float lut[256]; + make_thermal_lut(img, img->ch[1], img->satellite, lut); + + for (size_t y = 0; y < img->rows; y++) { + for (size_t x = 0; x < region.width; x++) { + float temperature = lut[img->data[y * APT_IMG_WIDTH + region.offset + x]]; + img->data[y * APT_IMG_WIDTH + region.offset + x] = clamp_int(roundf((temperature + 100.0) / 160.0 * 255.0), 0, 255); + } + } + + return 0; +} + +static float calibrate_pixel_visible(float value, int channel, calibration_t cal) { + if (value > cal.visible[channel].cutoff) { + return linear_calc(value * APT_COUNT_RATIO, cal.visible[channel].high) / 100.0f * 255.0f; + } else { + return linear_calc(value * APT_COUNT_RATIO, cal.visible[channel].low) / 100.0f * 255.0f; + } +} + +int apt_calibrate_visible(apt_image_t *img, apt_region_t region) { + if (img->ch[0] != AVHRR_CHANNEL_1 && img->ch[0] != AVHRR_CHANNEL_2) { + return 1; + } + + calibration_t calibration = get_calibration(img->satellite); + for (size_t y = 0; y < img->rows; y++) { + for (size_t x = 0; x < region.width; x++) { + float albedo = calibrate_pixel_visible(img->data[y * APT_IMG_WIDTH + region.offset + x], img->ch[0]-1, calibration); + img->data[y * APT_IMG_WIDTH + region.offset + x] = clamp_int(roundf(albedo), 0, 255); + } + } + + return 0; +} diff --git a/libaptdec/include/aptdec.h b/libaptdec/include/aptdec.h new file mode 100644 index 0000000..669537c --- /dev/null +++ b/libaptdec/include/aptdec.h @@ -0,0 +1,169 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2023 Xerbo (xerbo@protonmail.com) + * Copyright (C) 2021 Jon Beniston (M7RCE) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef APTDEC_H_ +#define APTDEC_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__GNUC__) && (__GNUC__ >= 4) +# define APTDEC_API __attribute__((visibility("default"))) +#elif defined(_MSC_VER) +# ifdef APTDEC_API_EXPORT +# define APTDEC_API __declspec(dllexport) +# else +# define APTDEC_API __declspec(dllimport) +# endif +#else +# define APTDEC_API +#endif + +// Height of a single telemetry wedge +#define APT_WEDGE_HEIGHT 8 +// Numbers of wedges in a frame +#define APT_FRAME_WEDGES 16 +// Height of a telemetry frame +#define APT_FRAME_LEN (APT_WEDGE_HEIGHT * APT_FRAME_WEDGES) + +// Width of the overall image +#define APT_IMG_WIDTH 2080 +// Width of sync marker +#define APT_SYNC_WIDTH 39 +// Width of space view +#define APT_SPC_WIDTH 47 +// Width of telemetry +#define APT_TELEMETRY_WIDTH 45 +// Width of a single video channel +#define APT_CH_WIDTH 909 + +// Offset to channel A video data +#define APT_CHA_OFFSET (APT_SYNC_WIDTH + APT_SPC_WIDTH) +// Offset to channel B video data +#define APT_CHB_OFFSET (APT_SYNC_WIDTH + APT_SPC_WIDTH + APT_CH_WIDTH + APT_TELEMETRY_WIDTH + APT_SYNC_WIDTH + APT_SPC_WIDTH) + +// Number of rows needed for apt_normalize to (reliably) work +#define APTDEC_NORMALIZE_ROWS (APT_FRAME_LEN * 2) + +// Channel 1: visible (0.58-0.68 um) +// Channel 2: near-IR (0.725-1.0 um) +// Channel 3A: near-IR (1.58-1.64 um) +// Channel 3B: mid-infrared (3.55-3.93 um) +// Channel 4: thermal-infrared (10.3-11.3 um) +// Channel 5: thermal-infrared (11.5-12.5 um) +typedef enum apt_channel { + AVHRR_CHANNEL_UNKNOWN, + AVHRR_CHANNEL_1, + AVHRR_CHANNEL_2, + AVHRR_CHANNEL_3A, + AVHRR_CHANNEL_4, + AVHRR_CHANNEL_5, + AVHRR_CHANNEL_3B +} avhrr_channel_t; + +typedef enum apt_satellite { + NOAA15, + NOAA18, + NOAA19 +} apt_satellite_t; + +typedef struct { + uint8_t *data; // Image data + size_t rows; // Number of rows + + // Telemetry + apt_satellite_t satellite; + avhrr_channel_t ch[2]; + float space_view[2]; + float telemetry[2][16]; +} apt_image_t; + +typedef struct { + uint8_t r, g, b; +} apt_rgb_t; + +typedef struct { + size_t offset; + size_t width; +} apt_region_t; + +typedef struct aptdec_t aptdec_t; + +// Callback function to get samples +// `context` is the same as passed to aptdec_getrow +typedef size_t (*aptdec_callback_t)(float *samples, size_t count, void *context); + +// Clone an apt_image_t struct +// Useful for calibration +apt_image_t apt_image_clone(apt_image_t img); + +// Returns version of libaptdec in git tag format +// i.e. v2.0.0 or v2.0.0-1-xxxxxx +APTDEC_API char *aptdec_get_version(void); + +// Create and destroy libaptdec instances +// If aptdec_init fails it will return NULL +APTDEC_API aptdec_t *aptdec_init(float sample_rate); +APTDEC_API void aptdec_free(aptdec_t *apt); + +// Normalize and quantize raw image data +// Data is arranged so that each row starts at APT_IMG_WIDTH*y +APTDEC_API apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satellite, int *error); + +// Get an entire row of pixels +// Requires that `row` has enough space to store APT_IMG_WIDTH*2 +// Returns 0 when `callback` return value != count +APTDEC_API int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *context); + +// Calibrate channels +APTDEC_API int apt_calibrate_thermal(apt_image_t *img, apt_region_t region); +APTDEC_API int apt_calibrate_visible(apt_image_t *img, apt_region_t region); + +APTDEC_API void apt_denoise (apt_image_t *img, apt_region_t region); +APTDEC_API void apt_flip (apt_image_t *img, apt_region_t region); +APTDEC_API void apt_stretch (apt_image_t *img, apt_region_t region); +APTDEC_API void apt_equalize(apt_image_t *img, apt_region_t region); +APTDEC_API int apt_crop (apt_image_t *img); + +// Composite two RGB values as layers, in most cases bottom_a will be 1.0f +APTDEC_API apt_rgb_t apt_composite_rgb(apt_rgb_t top, float top_a, apt_rgb_t bottom, float bottom_a); + +// Apply a gradient such as temperature_gradient +// If gradient is less than 256 elements it is the callers responsibility +// that `val` does not exceed the length of the gradient +APTDEC_API apt_rgb_t apt_gradient(const uint32_t *gradient, uint8_t val); + +static const apt_region_t APT_REGION_CHA = { APT_CHA_OFFSET, APT_CH_WIDTH }; +static const apt_region_t APT_REGION_CHB = { APT_CHB_OFFSET, APT_CH_WIDTH }; +static const apt_region_t APT_REGION_CHA_FULL = { 0, APT_IMG_WIDTH/2 }; +static const apt_region_t APT_REGION_CHB_FULL = { APT_IMG_WIDTH/2, APT_IMG_WIDTH/2 }; +static const apt_region_t APT_REGION_FULL = { 0, APT_IMG_WIDTH }; + +extern const uint32_t temperature_gradient[256]; +extern const uint32_t precipitation_gradient[58]; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libaptdec/util.c b/libaptdec/util.c new file mode 100644 index 0000000..e2139bb --- /dev/null +++ b/libaptdec/util.c @@ -0,0 +1,40 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "util.h" + +#include +#include + +float clamp(float x, float lo, float hi) { + if (x > hi) return hi; + if (x < lo) return lo; + return x; +} + +int clamp_int(int x, int lo, int hi) { + if (x > hi) return hi; + if (x < lo) return lo; + return x; +} + +void swap_uint8(uint8_t *a, uint8_t *b) { + uint8_t tmp = *a; + *a = *b; + *b = tmp; +} diff --git a/libaptdec/util.h b/libaptdec/util.h new file mode 100644 index 0000000..fbb1e1d --- /dev/null +++ b/libaptdec/util.h @@ -0,0 +1,29 @@ +/* + * aptdec - A lightweight FOSS (NOAA) APT decoder + * Copyright (C) 2019-2023 Xerbo (xerbo@protonmail.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LIBAPTDEC_UTIL_H_ +#define LIBAPTDEC_UTIL_H_ + +#include + +float clamp(float x, float lo, float hi); +int clamp_int(int x, int lo, int hi); + +void swap_uint8(uint8_t *a, uint8_t *b); + +#endif diff --git a/luts/N19-HRPT-Falsecolor.png b/luts/N19-HRPT-Falsecolor.png new file mode 100644 index 0000000000000000000000000000000000000000..eee6d89e968a8c6df0c20eb8fca772144df84f5e GIT binary patch literal 16186 zcmdtJRa9KT_a@pva7_sA?gV!Y1h?RBjRbFKT!KRg7Thg(j_cZY=*gBKh7Z4yP(t|Ng zZ_JRrSdTgW*!x~PQELOd@il>6?rG4iZA`ZQaFM?#KT9H#FhXUbw6i{X=upLYl+>w4EK%dat)jC-X+-cOlJSBJ1Bv2>dF9sH$4Cl5CQ-^yomz# z001`*0N}tB01!$A00=;ttzSjnDv-<-Wu*bH|G9Gi6eqk%P(gBfU;qFe_dhorAU%^1 z01yGlOG|2cE*}3eh_%#l*}aX_eavj1&0>uovoc{UE$sjH?`9AQ11J)JiNYa5INC;m zd1uxUxAsI9<#m?9nP1#!ug5l&EL~H2Lcd@iuhj<`E*}-yJ^GVO;ofIn{^w>~;ij5h zxl)2E&h5hRMv&o!h5E%Ax0$WBSm;N&mIpP2So*i^hxb}|5fEnc*MtVhPmWc-RSWS1 zIW@dE+NlL@$`6_~KKJ3$aY?rIOWG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A{{?07-ZuaM literal 0 HcmV?d00001 diff --git a/luts/WXtoImg-EC.png b/luts/WXtoImg-EC.png new file mode 100644 index 0000000000000000000000000000000000000000..e0f0348efb5601cc1b09f60efc64a06f560133ce GIT binary patch literal 1632 zcma)64Qvx-7=G{Qx@N3WkRJtyUl7KcZso3BsXI}+(J=~auyup+m$X}N+l}_xU9Xc3 ze>#MSh+%P<%pZ(K13D0=lHgEeMhqw>grH2AXvtKFMmC&t$i(@6ts7u4@tWM-_dd__ zzR&l*-}R~GMFsklsVM-UcP(<305JHj-F9Ae2 zfS)`7LMyBQM-c72}x%!9LEzQlj`&0uX~>)BLH z_P?*_XK%JCDMxEr2N>GInsP9J4nAZ$*(f+5riaO}d$ObJZf0#$e8~b6wZm;#8eky^ z?LguQ=56{oo`AsB9q?m+ha2-Hq10sXX=3w_|C2crj%s2i!(>`-l5TAi-ZZe^L7>$K zAF&to`0imGn6gg`V=@0q(hi=Rt!1JUS~8Tx(%hqqTgjL<6E{U2?(mE_)WG~CtbK~v z*R_6+Lxzj}XN`uvtJfDXL}A)KH-gjL$)y%Gl?M)X=Oig(`m{udep+#1;&FZFNp^f% z^oZ^g7F+Q?+k}lmi#jc>n&{4m&Dd*fUoX=R%~Ly-4mIU_ZG5-X_3@O>m4rHCq6HlF z?O{BJnBN}lo!CyhE;0L7n5eCj7f++D--iynVe48LcH`06Fb102;aJZp1k&zErmVrC z^Ty_Bj;;v$eQdDhFg*0cgtX|rPo}S0XP!a{Z+D$AHg8OtfaA>jBXwKcF&%Wm!M~R= z_kp^5cCqjL`J(6DDKS;Z*>dE-S-*U+d(Pum>OXj^?dO4O*N>Hzl|9q*_2BiME1}lj zAvW4!JJ__d_zWJrR5ia`&GoC28u5u>Gjm^6?R*a7W8?8gDG*U>fah%6OS)??Jc))E z)OclC^pjlRNk+XCmMZ+BF*a%0vq+eJGa(PMNrqY@Dgm#bNOG0pRYafh0d9XYGSlNs zMf9ptP$s2PKm^W47Dr@a;Vc~Ct%AiW*s@7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vc2*u;hv=>7rBB#WDCiO7FY|HhxsM` zlZ4J3p-F?X0@(U^=Qy7;Svj+X?mRqsKfNX6sJx0STM$V5P_eM21hF&Qm+e~pC~Aa6 z)y;u~qW_d(ETOaFUa4MLN$wrIxKxoG{sz><%RzeMOh%S9nvk1UTzb{$w~0Q!$tp>3 a$>{OE4A{snSsr?U@Zcz|uyxO=Tk{unh6XqQ literal 0 HcmV?d00001 diff --git a/luts/WXtoImg-JF.png b/luts/WXtoImg-JF.png new file mode 100644 index 0000000000000000000000000000000000000000..7cfcebe49af8fff0ff46dd49ac3a3d1dfe8678ea GIT binary patch literal 1637 zcmbtUe@s(X6h4It3_)S5ky#}-fX*t^`}%`wo!UwZ6bdSB)lC;E^iiJcd#}E}qTsST zf6Yw|g1QBqB+ez6%}veJWU?(X9%`ul8*kuNYJLIrg z-D@t~?6+>YZc)9_Q$DTmOtICrNV(+3JIf{4xu1$Br+2A8pJbR*J3P<-%=o#S$NAd> z+0p-fNw+>I(X?AWsyV)VcieHsQTEm3D+&1BGfssX0+0sEQMlD9AF|?G%J;WRsnD!g zlTsqW(EWZ@FcFGSP#LF&enq4^F|rzz&}d1^koH^pplO11dhe&o4cTerV>X;peiv@j zM4nA)v{c4h8b7?X)`d*cs)=RmmL5w-L@9}o<3J&S1^#gybWB*WvAOGoW*;wI8)AsT zpt;Stt{*bDZ`L%aEoTkwmfY>uZ!Uqy(;D~m8nKddbES@7%Tn?miFIBc+v!4bpR&64 z%gT6JJ~9Skhyfsh)aYU2y3Pb*E<3F+7CVs@_1+H$&mE9GT)x{b&4!%YNl7Ce`ELZKlag0>$tozJ3N{H_ZSdYi;YN8=3)8y0JU!p3bC7i&p) zoE$Ew^>Q2?Kvtm8)H)`_R0U{FWZZ%s1d#b8U_KboRI!#8SZ@F^T#eurXrE>_KG;N% zQ=&+L_KFP8AveR)fQ_gm%po1tVMOW8I=$IwKt*Nld%JbycM6kbhR-X~=4zQn0|Dyu zFqMZ5ZUWcmn~nPE7@IL3PIzvY?j?k&BMKt%6B4~_@F|>`F_Fs- z`w-!%WR8sy=xVtU2=QcMReYH9O}>zMhvcIZwg>3CXro}7N#9vjPvW^U&(4uqR?{ra ziBM9AmW608#0%(YV|%6T`9KHZrOCWPfnF7+x$1hL^d>EZPf!2;D#=ABR3ymi$R)-E zojm8`xm@Jo7?Jj&Qik*Ucy@5U;|L*)m5VtEFt&cIHO;~;f3Qa%=@7C%mdm5GMiVaB zIi37##ypgHgQ$=R(7;i%v_Z~qZLPROa?i;n7kWb>WD5&13zX4p!1QAFTawNmNfU#D z2-x&^=Q!W2Gnw^9dFQW9IxOFkbQ$g<%MJvHeJEdGwIXWPwwK!0K9U+qB6oc-h8XC| z8%xqTQ7&I2t|s>mmMj%{2kS?5v=EYSoK8zoS{hdK1A%H|gR7UI9JcS02_< Ti&utckUTi-<+g+KE7$)CXlUw+ literal 0 HcmV?d00001 diff --git a/luts/WXtoImg-JJ.png b/luts/WXtoImg-JJ.png new file mode 100644 index 0000000000000000000000000000000000000000..f4dac331cc05f9c44b1d5af65507c24afe4f989f GIT binary patch literal 1801 zcmb_cZA?>V6h19b5MiK0MVapUfrBC4y)C79b=pD!%a;gD6rIx23$3=d<@T0|5G_s@ zab}poCOXO7vSBg;;@mQwC}=deFm;GSlp>IgsUrvx#V^FYZyRwY?%&!U=k0mU^PcBC z=k}JSro{Vt&+rBSU-dFo8h`*D1>hw_q0N6Og#wYYEG-#e^LzmNc7VqyWxoYrBLV)- z2B0eerdbaBykao|MB2o76+FY=gC`G_ql_o7PLB1wDRB3lM<>)&&;V}fYLzl$)AfO_ zlL>QI1UB~`*hif%D}6ItrE0xg)7ocP2nbaap?=sVj3&iiK5Rr`hF5<+6H>rWB{fjbBx z56*ivnNp2l5rM!C3LwBAMjhY~1=HYnre4q_f*>%$&IzdMYqy~zAu7+F@?OgXcOeKA zD}nuR@=Uv@=9s&1uOi#c?h8U>r^DmSbaeYg$aYgC!3{r@#%DVav4urNNSC~c^r=>` zAeYN=Xz9C*x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NQkE-~1hsJY>Z+pWt;RtjqtN22xbthcAA;vOx#nE{1N7WM<|^K- zHsuio3}?kpoJ34fVhN#TcukOC;to{r++@1hsNskg`wAz;)XELEcMuNh*c4S=boRD? E0CHVZAOHXW literal 0 HcmV?d00001 diff --git a/luts/WXtoImg-MB.png b/luts/WXtoImg-MB.png new file mode 100644 index 0000000000000000000000000000000000000000..c4cc6d15646af8634ece154dffa6830988a612c5 GIT binary patch literal 1604 zcmbVMZBSHY6h6Cr?SKr+7-TTeYoY@J>%F_ItTzi5cfkcg0#wwoSlA0(+Itu8-bJvF zS)Fu>G5o+La;TgdrkQdGwZYJ=#WFK$oF+4qLAJ&whbG-JMv{`wyDMNb`lsC=_r2$N zo^zga&b#|kd0A0xbW$_`#M)L`Dgab?RDni~k8ibkEIvrx%8F8et&0G>F96)akoPKp zhXEL?0pPj-9&GMD{={+wB5O;EEHFjC2T#7!iIFJ9R%(sK#udM}p94^L*evF% z)=R&Ql(dhP&)e}$_Z7vd8SIEF*H6VeKxkOJJtcYH)wK44qu(c;ihD||>$xT-VXFWA zxxFT%=R@`3rs4kHd9D0LJYj2@~OSxDKG~ub+ z2ScGm=uh^(Z~i@AlLZd8&@^P3oXmrL_ zP3PF;KP^a~w{tMzi`bfD!vjb^^y?VXBk#;2*yP!VPj{yHOdT}m&B+nu9=tFXeI?TG zX?!azFcr4v(4Ws;kA}T5{`p;38@!+X=#SRGBVnf0-Bj`F(CLIe&_3iF-|E3)rZ>;g z=&|9iF^^y22GobYyz!TUNPx>Z`%%ox!5z%ZCA5;zYu>xPXzsH=qFBcgUruRnpeL`p z_=oE^cb|D%IM6SaWDFfK4UOJ{bXLDO>0ICfM9_$RX)UBQJ|~ zClRE2*)H>rj7OQ?J;+=XWXil<5nK|f5=0&tBPsSsM9=6M!WuZefivciqSC5~1A6=! z!a}NW*cG0uqcR?lXvk*RY$m4)>4v48(U8e79K%dTzS#61f#`Aw^=g87Lbi@UUIu+a<8#%N}W6MH0rceS19wFJ-k%c2CN}h$1-O! z&;N{Aa6&~gtxhVHP{CC$$>EZ+$Qnsdcn2vFqy~pe3>4Uoq9BeYTZP2X`WapBGN$Xc z_`!4?6gPyhY*uH?Wma@%;-6y3L#e%)6beorBzBpuS!yu9R&g1zxin?D-R&k8j~ueV z8o3;XUn>qFykG`KgR%ll?(EK)rJO#OGZ^X4pH1nbwP6_-tHAT7M?rZ-NnV_BV^)bffwSrxMb g`N2(Ax}0{I%Z2$lO literal 0 HcmV?d00001 diff --git a/luts/WXtoImg-MD.png b/luts/WXtoImg-MD.png new file mode 100644 index 0000000000000000000000000000000000000000..6a3dfc485ad198d178b6a6ff8ad17a2e32bae40a GIT binary patch literal 1683 zcmbVMe^3-<7=HJF<2*z!#jq~vYf=V6&TsFhTqPddfhQa)he~7W9oz!z?ClUXd`__opgt8KycS@Xgu+(q^$ME%w7R}(}XER zNi0Z8lmQ>xs#WVw!wE6gNun9 z67O+_`lE^OWSFDsSc*7Oj*1i(X{rFpy&woEVYJm~hj-wi=D&X5(oPNEI+ot5?f6B~ z$CXVw+H)$Yvj_YawkwWMB?}q#CFT5A-zIptFIxL(1^q{;p`5W@)O(9E+{hCC+~XnK zUfbj@YRE_?CXcUE-O+^QAtM}KcA!#y{Heni-cN5mN{w6JBwJP)^>I5Xqz~Vy<@9rscno%uIgCHQ7YLuiIqY=22479ref+MEnDpLB^Ij%|lz$R(z=+bMDn|5sImGf6qE}>m=}+VRt%R8xVTz1b zVg(+Ruzm)x3C#`hNRRax(FUvDU^N+0zN=(tyPiDNFilqYyb@zAmt_nPq9GI0nb=rD z=mxXZWXQnSit(SymKFaJ_yr$ZQTJfMh9&qc5u}YeNTi;iO+=@Wb$KFF9b)+MI-m^}9gV-rIDMI5kqPCCvO981QNu!k_X+%T zw2)^d#)k@6zS1Z7`*WNh62W*mSs@`t*N=6UEWB;R|Iu9^BCd>LnY7Mi!MR&9$U8P# zgUcI0c`U~OPiN@@e5LL6;)?{ED5sq74F-`tBt}c1O;#gj7Wq#S_{mY26evo7E%$bg z%~rj|YB0$=ZH<;5Z(nDQC-BsW zR;Z9xl6wb>OC`bSuS7MB7?f|EUPse9Jt|`)ua-(^Cj7`I-2&$o(Y<|TVjaC`MQ8@W N!RaWn@6Yix{talD`UwC4 literal 0 HcmV?d00001 diff --git a/palettes/WXtoImg-N15-HVC.png b/luts/WXtoImg-N15-HVC.png similarity index 70% rename from palettes/WXtoImg-N15-HVC.png rename to luts/WXtoImg-N15-HVC.png index be332897838764c88b0b50cf01bca5efb005a69d..5ed0892940a93ea77936692a74320430180d7218 100644 GIT binary patch delta 161 zcmdm3)tN9sWul1-*K(!zsB2&nVrXn-Y-VL@tZiUm zWnl1|ts{$pfkCyzHKHUXu_Vw_P$~hJu>Z2;k3yhG1LZjC;F%S;Yau3YI}*0#b5!L09b5m6EuV)_n&0OTY%9I7n>AqvZmRMR z1Y`rUA+T`6y7lYeJIQYdUu1*eQ=qD%f>u#hMWfMbYO3m*dRm$q8k&oAbQkEE8kw7! z8kv|ZUb@0^@e&-?#Kg+!6Pz8MNF|oyQb#0{ulSeOYH+=j;N`BWMH_+ z=;LLUR-Y^OVv(A2XE;sM%^Z6J4U2?hfN?G|gSFc^KW!p?dtC7?du=- zi8m}5866uJLJub%NuE7_F*)_}mGre7nH=eFZ64cu$h2W(N+=W(g_a{jC?&|DYonAc z@G3gw&FH<+x=RR$RrS{76xZBV!`go#)(?!ir~c7W;_$~3IW`5f-;hCn4eiL^!Zr^L zM)npM4`?D0aQ=|mfCR=?Ti)-8h@jW%wnDmwmr>1Qu}!JD<7Yb@nudkBW7MG7njl*9 zw;KhHg{w<3$4!)-a0L8=0g-7^uIMB$Whf)1U@AlEht)$6O)EBFdJE8$u5=a%ADm)X zxv00-iFSI&=^;v^c(p^K9eJ}Ao|qm)DVow|B z)#pq3W{Q|p*gO%KifaqbN6EncZ1upv*qqbRw7$lSbXF24lWh52mjYV7;SaV34E;#4cxNQINxdPj{G}eok83ADp!!*xyQq$yfsOdbrfyg%25d;`lTj!7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zsdt)ne_tZK$`xwh zC-4?>N3c2*MOsy6w{CUrP`YyB!WB%3PKU-@-~4vhI$eYD`7_zf7_1 z-{>)#A!<8uL=d}T_EFhv+4XoamYtujXw}C^@GI?@!6L`8Uw!bm-&A zJwvaD_JCbm#cGX2OX&5OuR=-B`&km>-aG!3%c#ufVb85cwJLHJO&gY}@y^tuny72L zulDTeEP+y+l{uy^gGMC`LSxO>UM%%C?^~Tbe6VjZb&C{a??TTtw9b?;h*FTpJ_Z6l zGW}#|o_^As2Lsg2g=-H-Pt{97^0>xn_mwS_w{p1N@f5Q@s)cTbwWT0&-Sq%U_L3ad z?4y)=8jizJtKBJTDI*v04|Scj>ayGYBB?L_*vqVQ<}b{DJx~{C zFa9+U{Nm3de;ANF-FAHa+yLt(zMdyo{mdfB>8)?q+}ecarF?5Nx%?p~+LC`DH;+6O zlk(Neb^u9#)a+@EJ$GgWN8iTE#=*+Qev2*9nc(1T=V)PL>uh7A?opY4F2X|hPr`e& MwU^%PvKU1D7sTvbmjD0& diff --git a/palettes/WXtoImg-N19-HVC.png b/luts/WXtoImg-N19-HVC.png similarity index 71% rename from palettes/WXtoImg-N19-HVC.png rename to luts/WXtoImg-N19-HVC.png index e6465ac646010d10605abf5eadae933b05a7cb9b..a1e88963d608940cec44436aa1c337e3d4f4dc7f 100644 GIT binary patch delta 143 zcmZ2c*$_WLWul1-*Krv9^JM zm4U%;wvMdH^Q^@EuuFGE8(d>xV9+RWjVMV;EJ?L0$;?eHE=kNSU@$T;LepabG4j5r M>*vkqt!^>`0Ca#WkpKVy delta 3579 zcmb_e30M=?7M_qmSVELd5D17-p#lOifGirKRjNJ#H&9Wc>_h=sWRbw2C<>^E1u7yE z9wJl-0VM*@lxRaiEEHsKum-{sQDYMkG_s^K!B$_}*YA6+H@TB@?z#6){{Ni$?<7;o z;x8^!M+K3$kpZAOQ*GvuVwQ=k>WGr!0t4KdiADX@k(1`2x=X;G&4HUYuLP6fL-W zzM>R8&+jY8X9rbv=TKp$Xv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C;zuWfAFQx8*bV);CCgbWq(qa)#iE#Z@;(FXHC@mBHc3(AJ#|gF4 wP8szEgWgD2aH2Djh<*X{BeN>@dz}J(eTkdH37jxO0W&i*H literal 0 HcmV?d00001 diff --git a/luts/WXtoImg-TA.png b/luts/WXtoImg-TA.png new file mode 100644 index 0000000000000000000000000000000000000000..dfda1958508e66e82776d0744ce133fa0418c5dd GIT binary patch literal 1553 zcmbVMZERCz6h61>O0y5>;)uivyvZ1@87ud;>$+8g?daG#wlTMfbK|4kdb?fL-j>_j zxlUXP;s=C?5f;ZlG5%mNLl~1N8yITTU;-qYB0+{)vyq_&vjj0iL_BZnJ~a5p_D65e z^E~Hy-gDk|S5;+6YSJS~0FY`gwN(Q!_{e}-fgfLKp5*X@G?i9Y0CX$|2=4^=9ZTUG z06`YuCkKGJ8{lF8p`oXqKtR>Fw!{Ya>HD3Jd-q{wo@}ouo;SfLQ$9Z4JW}qqsOw8htv_CLe`!A&DM{RXK|2=xqqVDlaOvp#KU^D4#XkS@ zHTBr_&a(#vzE4X)1E-jX3NpZhkL^lD1}H%ROcKN9OVvQ{tVn;1fx$;N^ielCq#k z^sJsGoWZO&n2mX)q@s4JM~}ZL$f63DQ|8T0RK^1m4Y@3r%jVT0-H>lK8gf|H%(8b? zuWtE=!0U4f?$Cb=b~mt>QII|3AY-0@?DYB{pecx(d~Ywlg_?A#u?Z62L=OT1A5N^% z7ZhDtSC`yIJT~EC58oC$D3}WP+gn3eUqN-nBF?gj_wu3)wN}y);KhJXA`cqdM#a(7 z3s9$_x-}BNHOPxiA>a%q9mk%_xpW<|*n~P~9pxM8_Zbos;;8j4StEFO5V=B~ zUu?D>sQwPIhiJG9CjIfw&1LA_fBO&h5iOVUuDjmY1w_in1-V^a9o1+j@J8fNU#H z4KoCm!7?;3Nr+>Mn_-W{#5wG@eb_?{Zc8MLW}Cq{m2OIKW0^bW77!Esvi8I6`91#6 zbNg0RWl3E0hG+nYGw(E70A%E+45H-ZF`lrEArDl)(^3J@wgtd{6yR?H`ELUFFu<)k z0DV6|if7=$i-m-Uw3n3_;UWDFeKpcckTs&Y!n9^u77@2uUwXDr47Y!LGKA}&u8~<*i{AdEhNtW{&+s>vk1|e zvojaI&%VM#vj2lsolztH)er;8upv57iy|PcBOv!f5d@zGU3?(LRs*9DTpPO#J|7!6 zP*o`JC_$ru!1Gk(AtI@h1>}KAc_=xmr>IUw>}zB1N}#_CM?nP0K}Mq@crXU->$+Cc zNPx+T%i5a=A?AtmKPHEx5W?593Cn9Quf=x zp!`l`LSm(iHZS#2LkC0h_$SO~lBnj|zCrnSe+~~lHjEWY9W%|GHokiMmsN9@{IBPw z%dXs)fBgHcB<1|=o=$e}`yoh{nz|d zUiYtsm(L^>gnCoTGV(G)<8xMWUt&d5jc9O*PSNLJL94_+H1xeo@E8eib8hmr9K|1unHqatyih_S`8|xus%4YA}z zV}S_O3d|_5#!BSst$M9G2V*_P^O2qVA2V=nhqIye$%YfP_(x*MTFM}jdc2~I^Q_>> z3n!T}o9+=$67?9J0$WcT0k4}(%Y;v*9Qlp^DV`mSx5T4E*30r_H#P*S7+r)+rhMbQ6pNn4Nog(W%Wlp});pRfc=Ff>Co(3x?!tnaBQkReW|K+||%tOqLVNSs) zwK}}LH;4Sig=?s=dC(50iv^y^S9Wb_H)5*V#sgW28OH-yeu zqDg^*2w3-M=Xk4LrPHgmbm#3GN9ip|r1EOAY?q6a50$$N2E^od?HxS4m}-ec)>cng zarawAJfSyBUU!3dh}=8aQzN>~Tq9~`1uwmEDkZ}xRmjeYwr6B9$B16qWVPF66VRi5 WDX@~+z2Em7;lXUGG@dK2JMteAAHFI8 literal 0 HcmV?d00001 diff --git a/palettes/WXtoImg-class.png b/luts/WXtoImg-class.png similarity index 63% rename from palettes/WXtoImg-class.png rename to luts/WXtoImg-class.png index f247df78165c5c599e548530b8025ecd5386753a..3671566dbecd769a726b97455c5a20daed3e277c 100644 GIT binary patch delta 161 zcmdmyJt1&{%0v?vuIG#_yegKL7aeWb*u<2sLV{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b!OKMZPr^&wBk{KwCPRq-0wI@VqW}N^ diff --git a/luts/WXtoImg-fire.png b/luts/WXtoImg-fire.png new file mode 100644 index 0000000000000000000000000000000000000000..35b997aab49c7e1958db5dbea6f859f3f7037454 GIT binary patch literal 1565 zcmZ`(e@q)?7=C*cb`~o&z)W16U)+W)K>ekY3AfVV@!ZV;~zR^4eFNQkHo2om`q|^M2(6;qH#ujzq`^xqP?Vd_df6Q zKJWXyUwgWxxxsF`-39>m;GRG$fCV2dz;k%J>bPIP8|mBA+5|9K0+4(R;7<%CmjDtJ z;D;Un@f^TyvGZ>|unU2_-hB-L_=jDSv#*@N$R<75RKMvvi`Bke-22*D5r7*H2K?>A z3qLK)KQ%`k0sqm`rOChC@sj&m?L%-E=;fB(rDm}!w$!vQQ?n6{<-O1O2I1P;BE&SmWPW>4A3(>x@rXuRCI|L zkTDBFs5WdJXD;FkgNm*Xw6I}WdM3z&?bqpa(G1YyP704t8^ffzjJ3)ct1$~a(_`ux zi(_0fwrpVX9`W569 zF-}0%q&_wX#8q^xS4}A49Sd7m5jPyJk4Qttpx~{RR*#He+`)MD3VPWmMI}Xteys69 z`L^*jY_}#INk~fH2ncSkQ=pg2KD&;X;X;GP6iAzH7Hw3Ou&R`k1B$FmVX{wF2EuA| zxiufg*h?GH&D0-An{btIEr`|sBD(6P!N={~1p3}+vd6igpOQ+8LvT4ItDg5ZL$#A6C+dek; zz=OLX^_8XA@9SMtJzu{)yAxCaqOsxrfbz~XYUd;qUA3Yg!guUVpFC z!o$;!5b?ciR?cS_@DZvVL_%yCX@XCQj}k8Pbj7Y)FxYVhQI5A?I!m1SadNC&)6zi9 z`*0)9alze%a@=kdqQ$8BDV0rg5-iV1Xe|m>z~bSk@8pXzf;~eai(K(bVSDrf-uux^=-&lxk@K4kz zX1TcX8>D@2#kg#G>_}gKc^O$YxnmO|sGX&cK5?`PyT_XGUKZ5g3?^l81derO^(C2t z^`l)Xx#IMx6M+0wHl!(gW!E*!uOyp-@i+D$$;jyBN~{^qOHw6R8baTqI{D>8N~;%s z*niMEBi6YDI*NjackW$c3O*eSS!|U=z?j-A%goxe0U6Z3a|uh@#&_9cN4y^S?kH2; z4yDZtPX-LCUfF~9)yT`a{rGu)D4szk&V{=^-rZ&C6e}{%5tchMisyYE_j*HrwMzGQ z)Wo)f&~)>{uZT2D%3d#7-4ZAHT`U;1)Qy_9!zey89N*4){8Amzlwn`V%{mm0!{OC+ z49~M}(h4-0TF?2oDmS}yB(A6x5f=WNunN-2RH=>?J&c>=_!^NBS=Z8)RCfzvri7Uy z%SfESlMc?q0%aiA`gu}E=_r!cn{|4#A)U-Aa6CGuLth~zV}*;6SaUU&v4DvBG>T56 z(jADdUtu=rH56s0s3+4t*!&-XM{sd9fmaLmZlnf~AoWEB3Hk9!jK}*w8dIdmus!=e z(#*pe8z-{Wcq8BwP{*nSKkrH&T=)>-;SOiJ+4}HC!DwP1ZV90HY^=-XQ7@}m56es7 zW0}NyE&9cP3PWo|c8j0os{=smjar(zqPhM%!op3+5pe;sREp%x7kHPzFC*9SoW#1w zJdUq*37&~n_R#Y>`G^>qFr_tSP)DacXP?(W;@Sw7Mr#d5YV{!v`t3zL6fjTS*k3W@^N}{c7_mSb%;^+c=J^T1NiSezP?Uf&z8ovH!mKlz^#(lF z#>CV3Ak4w^QZ!Gu8`+1#BCD08Gxk-SXn0=g1xPvq-Uws-TH0&`FAi&k8fhy!T2Q`T z66~H@vYr)v_)zJzG_BQ9%dzEwd EKk_-{PXGV_ literal 0 HcmV?d00001 diff --git a/palettes/N19-HRPT-Falsecolor.png b/palettes/N19-HRPT-Falsecolor.png deleted file mode 100644 index df1c1fd1b7b743f6c353c768c1d0fe18de416028..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15849 zcmdtJRa6{b@Gd%daPq^Q5Zv7*1c%`64#5X^cMt9m5_E723=rI9aJRt;GPv8}f6l{s zxcB|8bsu_lcRlRASMRT?zxsAnjHf@ z@^5S}I5|8tjBJUa_B}mG1E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8FkeNwzQyX9iQVH$8=zDx%WOFEWx~AH|;C0@>8kghcaXJb*Cq3k)~N<^YoU*Zh&p zkc1eUBKhNLmm(QgM%dk9;=;n<_JNBll}aF69NL;2|Jl?Rkl+y)KFcxOWH1N9izTwG zAWjUdA>g%z!*XH-6QXJCNThlwhGeoKh2T%)_-Uf#_CtP2Cf!+Ker&?md>N1o$)2H6 QMi2*1Yh3J$SMA*UPavl(0RR91 diff --git a/palettes/WXtoImg-JF.png b/palettes/WXtoImg-JF.png deleted file mode 100644 index 1ebefab70c050ea21e49e3c1b16b5fb7a1747251..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5005 zcmcIo2V7HE+dm@03E^8e&0)T>36c87IkB4&hMEJmjQ`{&3T+Ni44HAVkE@bUSHvo3(0KnM`zz4X* zc?Lin0e~0V0kA#|fO7QNTN`X4Lo9fmvjY$ypZuSSPrwx{+r`ZhJ0vE$NKLs{N6-j> zNV$sx#XFJ9@24DoK~~)VzspG#28`d!?5!NH9^TsJ@-1pL8fJD8Gxp&U%BvVY z>t{b85q|C9{PCl!ei8X{SoPL3BGsr0`VPqFy+zXDWa+>n1FzI+Xc(VZw znD)3l{lUf3N6FjKSIJ{i%!dk7iF!p{>)>DGSFz~L3V*{4G z78n1V!Lspngh!~88<9wlHl6<%sZdJs&r*&mk5FgZ!Vx(7_+c=+K_BrS(BmsG4^Z!! zp2vMMe)(AuXj?+x4-z=PGs2<7l`W-+)$W&-&}v=$ZF5l;x;M(Ah|B;pbB`6HF?;R- z*#qhN5a}NxRm7laP`>6wO9uIW0J-4IyBWG-H;D_XUNn|E@3V%DjgTAa*DI= z?c?jWY4etlP-<9s1T8X_9T%UFn6xu}@4o#94jwvu{KUyq+25VcIrGE$3x!3+7k|8T z?RrJ!jhj`~w|=f~_@%MwUi1Bqhn-#BJ-v^(Pk2vvrW?nV zf>{qFzgcGXWcdV=nlQ8fU1EFwtIR$p_9ZVakVd0m@zCZ!>RrGJ0w_B_#H0NM_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IF`OgGk3o766GR*m9CH zZmM2QG29)_vaNsTG)U~xc!n+?Z#lSUGO$+MNC3M&0F!{)KI`SmgZm zuS(cQ|8B zEdZI@(DT*Jv**jr1R%S19|-(su(yBzpf|-U&oM1#s!9NMjmRH$UfC4+K}5D|BvrRN z#X$LxiQ#CH)1|=3%w<_MbB|N2@@4DmWh%CgHx*OP@pg6`H|j9m{yMokVc(mKbMF_; z@11O)wi@|zi0Zx8`+S6IXKMeKjOmw~4!F+u*1W-24UDdOWe{TZ!LMW9F>$PrXM(0& z?5~e8Q>Iv{QEytoZo#9)oz1cE2eUNWaTA*o#ip_2LaD&qn9vn=@)TT`60Yy0 z(c{<=fJiVuvav4$E-N9+Ya)Ue3~CgP0*E-hcv>tiIEt!2sN``R3TXaWU^Otq>9HfI zEP7BBj>ZUM1+l21`Zk2JV^C5@D9NG*v1v>O&YMQ30)jctHI9KJ5l93a(bSq`YHeNKT8>fFcwx}MawT;#CJC+^ zB6^Mth)W2SPGzuxs}s&Ymdc1_vT*+nf^B(AqHaMwIYiHiMU9E0GD4C7(bUqINN6(X z9ELn$w$3cXJI;%};BY;Y5z1s3;(Qo1HZ>Htj>ZTNWzxr2yIh9~ix6Y$q2NL(3C5OI zgwyl%icfx^a`*zzh-hqXNmz5j0REe_5QAG#G|q_@MFk9^m2os9oRYKgG2|&ACOv~< zV{r~~tc4JW=GJBesxSRl$i{zW!vI-qK(PE$KY|5P5L0ucekmGPkc!JA;$EXOa`l;s^G=FhkQi$*S_Ik4gu2Wyb^_c(z;6?q=|T_3#Zy_a$nGH- w6N$zoTria#q=u5(2jzv8^kPN@v2b7NWkfJ0`bNf?Kt6DBbayCQy?xKW09V8kj{pDw diff --git a/palettes/WXtoImg-JJ.png b/palettes/WXtoImg-JJ.png deleted file mode 100644 index fb46ca872fe91453b9f30dffb6ea44d6dd77900b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5169 zcmcIo2UL^E+MXmp=tWRaS~MysEeWBc5Tyu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tXwMLP`SgqI>Fnz}N3a#?2P6&J^J9Fn8m6$w{p(Y*bKB#{wrd#eAF1Mh zsVjfJ9P-s#Gn*=k^2+KMn2FpHvG5R^cO7LDT5XlSVLzh|zYBe5)UTYAiksBPmg_lQ zgsP6WZ@JnU(0G|!BVD!7s!Q{7KB>I$j9Z!FQ}^4AJ@{a+OYs|pAY~h7rnGMAaz0rI zPFL&)et!@5HlLe1<2^F$lOo4Ugkble(lJN#+ORKZ`L@9Xo%VP=)np_6p;(9Oeqkw# zQ_H4bB$Q;zS5?UsZ5^)7rd;IjYCd7mZ0!Fbu6^hJ(IXc>E6nU0Yn-qc{C=+enBbhF7&sDvM8FY^ElI|fCS;tW%f`>=Nbq+Vumtf4 z4&YENgAg|=Knx8CrUnF)jYP5~$;^^O)*}!t2?TWA^DBRHpfiJM+hhN=13QhX1|3w8 z9qecU^5~5KxPypcnMEy4C+N}*@si3ML`2IbLv=RER^dbe)bH=OAwV#WpIGA zGtP%iWw4nn-2X?xwx-hLXy~Vi_&Knskx^7eP%I!Cn;8-bwR)`sP$xp`$U=6@V}t}V>BFm>Zb1hHWU+P7a5j|$Lo*A)*%^A#@B2XKkXfAp z(a^+y85U&(^}xyA)h=(9|DOK?*q(YM diff --git a/palettes/WXtoImg-MB.png b/palettes/WXtoImg-MB.png deleted file mode 100644 index 07eeb50cd685fd17e7d34da30fa5a83d46546c62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4972 zcmcIo2UwHW8a_#YgbgBs%wVjbtR(EA5M&f7!v(mQ2@oU+BmqH&h>D5>aa9x)uTreY zQf5WLLO~P?BCDYaMusaks3^$DJ%4bteQuxU-g`?;D7``15_$-1bEQ55u_-)a=}B%ALlGLpt?40LCJzF z)Wq`7W=hZtM%cEq6#6Ius^lQe`gc(f^^)pm$0l8P=Nt#0?@@0F2-i0qF<^2}=F|21RIKW8!ZFAiTV`zmBd!8QtZ} z#N*PPZ(>};iGE5e=-9KVnK)>!o_$V-cIWjZ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Bn6TsLu=41dx9Um+gUU@pxz6mg>g#L$>%X-u?OM>4l1 zTiKFq42dLLB2kcaeeWL}7%VD1Ea9&ma#}HV&|yBZgEO5?3q_Iw92P_$!ir^5zvAhP zL%od=x|DPz>qNDO)EA&%B z{9M_zm{=M!Gy#yztV~G6X2Y&ws1u`gV@^ReP6Y|+6U^b@onzT^DUd8|&51N$#$Bi;d{V;%*<3)h`dmMvB~lPG z3#5KY+NDUvl@ar`uy9dPFn!?VO`+gPHU~H4CVt%NlM=r!A$rc@Wvj6wR4*3$vckCA z;28pb{#=$jBOD(`V{?$xLpC9iOvv~U8aG%ICA$aOiz~U76&1|Jf3BA?(S+n18EXpl Nz}>~mx!5Tv?cb-Q{xkpp diff --git a/palettes/WXtoImg-MD.png b/palettes/WXtoImg-MD.png deleted file mode 100644 index f350074d69f69f1104e7d78403f232611772e7ae..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5051 zcmcIo2UJtpy51py(4`J4EgA)smV^LO6oM2HX@X#-2MCe`LO_rf!GfrR*hT~dt|E>I zr~?X$fCB?I1ZjGM3Py@8PEbL5?mofMnOSe%dT+dQ!pYft|MmO+eg4hLeh)V%Iq8Mc z0024XHTLTPK*1pjNQ%Knr-BU;J}_YvR|)`^vt*_N#o-(myk@;C06TR6;Oquq5-xFG z0uW08;B^21mL~yFi^{w1X$=JuK`u`AK!|(_Z!@m&5>mrP#3{Jjs?E|qrNgUe8BFLGh^_iRg-w;!=1-%Kk%?OgS%#fMW#U0(jP z_Fn$}(A(d>YBzYQ>{+HzIypOQCeA|Z-Rn?M0M!^Vb&w_&r6#EkFu-V6g9JcvKz}1z zfRj}Rk>C=_7APoluz`;O4k&;S@qRNsGaw1X&{66t>OdoH5rK2z!a9^X$b*`QN>UQg z+8v0tjR1^vB~54vLqL}}eQ=EuExES~JdyZC0_+QjlERpQ#~=XB0k%MpjT+a(h#|4( zyhy@q{uahI9f#GLFFUs|b^BT7I>+Y}w%(DEWQq zNXT$9Nj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V8)C zctE){8#kpB0DS-NqNRj=lm3R2zWAKYsd?t5Hq@56`q7A1KL zLDn|(Y|WkNGZkbZI8na``2RE9+l)VaoaB}7uq%43S_qPd6u);`(GoE!Cf_}jqT7?C zueRUVU^v0?f`3HTlI+@@;M_3#}22m z=z)Jv8f?A7aAihgh?0JIsXI=<{{43LB+XJ5{%3( z2q$OhmA}P-#$j_ZL!yzXIbrotefZncTn?^*Q8-6hBo#1-7DiEwFiOt)XHce$xbz5& ziNV>&vgT4Cnp%RzyLk&!Tc z;O0)D;D{CnH{~b(7V3)-=baEWr}6H-;XEi_BC=(MvUk8e1bjELna=buTpX1ZgX|uX w5s_#_!Ua*;f$AukJy2g%NiSw(APe`kUWNoCqEAGuF_Z&m2RHk2yMVO+0OYbE-v9sr diff --git a/palettes/WXtoImg-NO.png b/palettes/WXtoImg-NO.png deleted file mode 100644 index 44febbc2c367da8b8271d3638b9f8ff65c4ff931..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5430 zcmcIo3p|wB`#7mlFR(hJKAk`KcC;{^Z)<$zwhgv_nh-Q&pFTc`#k44K5x2< zlf4{SjSK*gb6B@_695QoB7lT}uX|K$CVb%nZ5(X?IF}(iPaCbEfZ)5qel3uocfpn7Z{Y}0=&x6ulzbNA`y}}nH)Rq$)Kr$8XW6;e?amn9kyFjETkwOS2wCD$ zk(Reeh4VvtICtI1RGqR+8DF^K-R;e%i`(***LA8Q81U(S8QPtTsDVxD9K1IkqemSu z;cP^t3hC$oEVp>A?~6`#j>C-Xs#|C6n5Mj4e4ZLZC`rp@KBBxVeA?NT3?wV8sMT@!M6hsRS4ldqxm|OSXgW zF@*?R1$DlOEvBoY3m)`t2L%YN5V6AlOvV)=W0!5xgxHQ? z@&Lh`t(JqSL4tz)V5h(%d7XTNH-mv^1AkM_2?S!WXYj#w3g=!B(6|aGHG;EeV;LG0 zN5l-QB{cZCNLizBo?hTURwD7QmmC;YzP_JvKEvDS=P)cM7#l-gD+FgiW-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V`*0H?Bm4h0{O;9xytQh&BZqP{X6ew8{9SaejV2pz5C7n{PzlTsT1u}=7XOO zQQgZOp5pej}{S=|_#>`u(EA zM{FjAi6L)VL6YRbf{vC5_zyEhWV=OV6C&b?BK^6*#E{V$aOf}`mz9q1xVi8A_Necg3 zG1h#m2S5AG`{3vkMziCEZ~>obZWzW7w8`1@7|N8;DP4RbB4}$Ph4U^jO)S_9u3P9$ zD5n1*h7JlvfMND2LJU)sa$^%TLh+gvXiODRbypagkPzrTWWmOU#xy^$H4lC`oL}k> zA#HPP*u2K8TLubHyi{r{2oOcXECKFYL;{D!O?;v=MeiiiQjkm(j2X$0lK!PaSQ*=p~U{{e9@!kGX7 diff --git a/palettes/WXtoImg-TA.png b/palettes/WXtoImg-TA.png deleted file mode 100644 index adcec9b5a3108ee5dd9024c85f840456695ebef2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4921 zcmcIo3pmv28vp)g821QExlK)lb(4E9c|>=Z91bOa+&k}N4MSQ?DL$no&Cmt=KJ3J?|t8SKhLDPIy=ZnE|mlT z$T)7Wa{~Z@TLg%Uz>oWKHYE6g4W&3y04Ph7nhg+zXME5GHzxr0tO9^@0DyOp#CZZh z3=x25{s35>1wc9S{Eu6#Aww*1lY<=)ps(DY^1p=?9NW>!9ycr|x=3}2&4tce0EqZF z+EF~>xV+!)eP3X!cpXL=gXHN^(Y(4qP!<&poEetTYs1s0ZNg2d1;hGP*J-z zATN%ZGy}aLavIc#{VXPAV8IFhNN5+@Foi7CMLj{T7h2+rV@<)1l^nODFuo1Ll^rM% zb^SiF50QKb)Ek)+Af?D>WKJ@MuMRPNROpBYzA1r16ay&O4*?0C?c|r_gpJH4XNgp& z+1|Z=R-_t{Zt#~J7UR#%ZAKi3e{lS!@jL(Pn7B1LS8N$z$ow1>KR-s3G~ZA86eefQ zv<~)Hq{i3K9dE{I9twcg2J+=l8M!I(VSTxKNSC+MzK38k$xJjbgLZB+f@fi>5a4E3 zKlYj=%7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#-M>}`hL)!Jih%HzuBXIjiN^Z>33N zgpRSNzGcG+o_fvo#|RP?ah|Tu6C@j4T{sx1UB!L4v+s#6Q~Fft(Y0%J%vDa*+}Rah zRBT;67}vjqJA_kunxjyxb>l{dx5VWmXD?$fDYeVL^U7?qu2fbXUATm`G`|5pf6ts> z6W2qpQyQaC38OD<9;HU&2s$>bmiWwD=)5TVPK|^qklxmMR39sPu0uZxKu0+6;7Ghf{@d#S`&0M67M z1b%-{?ro;-^(MM!+wY5-tP+5vQTY=N=FQ>nL}a^1leKyhb(K>M^~U1YU-Ju3TajKf z_b9n4SGJ)+rhEs#IiHd`)zDW1e?Z=38n%Q17df`=?qAh64Lk3=rQatKq8tPck2s-WF?fm zE-Zk-phn;+fP~kMrA5;MBd9t9N-n3MfX3$nYk@Idn;k}F(E}pzG)4$3fJF_~u_6|q zgp#X-k}PTfo5p0|J!o_)Ae!Je#xU??BAJLM8CjBzEKQ8@4o)6Z=g9E)39u5?2o7LV zErU=sDnJGGiKhBQ6AzNHCE3i9Y@$mfSrUntYkTB=r$A>0(?a6^T%mi2Q3w?jQ4e-B z7BvVB3Pdv@`aot3BX}iOV*>Jp*|LwI#tMT5X6Dq1sCY=%L-p(#FfTz=I+ei&9u&M! zG?fv}Wa0l)3U-PV-dqIr-YmyScDqe3S~R3o$qaMB>-eBB+2tvM`8bgierKANc&LS1GEdpGPM;I)m-bfkykW2vlYw0p<~B$5FcA4p{fs3KAap}eq? f?#ze)7XDMc^oa%}&+r&S$On%0&UVFX{rCSHz3S?y diff --git a/palettes/WXtoImg-ZA.png b/palettes/WXtoImg-ZA.png deleted file mode 100644 index f385fa4942f1f6f4fe56c3005969df8456cdeecd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4922 zcmcIo30PBC7QR^^>^p+2(WqeAk`Q(jq98?N5fM<7JwlKqkc3UPDDGMjw~B(`AVNhp z3j&n_4i2c5f^0gW3Pu*UXiz~BBy(TTYWua{H&dtg<-K>$cF+0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j$VNB4JoGQqgL${rylVeg78+fuCSG$$ z)vi?@_a$s1=fPhlDKI{XcJXx6!QV?$2Z*f$&jQPOll{yZ>kbkXDiZyCyhg~*xY}sY zQ)49jZR?{!Q{ z*bCY%8Xx>~o1L!d==RGFVPnI?AmHz*^UD*v7`561R2s4WmGk5Mu{h!xhIoXZ--A?~ zWC>7cge52W;I##1DQ4-BY$w6HRXyYf`hyt$(A|Bz1~^|&J}#Uryu5uFSDTxOH}B#n z1{AbR;E?k-pmO`x+i{(jFos`J#s5@SK0h4z^E&eH*Or%5H!(3|#g*8YNat4%s>cjE z>jI|ggpXatSZnRPYQu{TIxG!yt z{(x5P>`yc9N-@>hZ)rA=wCZwDbk^eR>dD7xmHDayflB$7p~gb$Inj=`W9DsE!LO6M zw(og!@Z5W~sof*3WA^>Chp5SGlbIuQQP!gWQ84ym8XEC_pCJ99s7%3QlVy(<`Gwm`qv>feOe3lLR`49vVYi(xdHt3@R9W zs;~lB6HK^KG&Un7hCpXVutV6i@Fk9dOCCc&4^paGH%VRbx{Kp{~` z1hSO_#md3Pn&9r~`~DOK{*M8^LM*~VxHN|_#Eb?IMRSs^ImyPCZ0$g?bFi{DC6OIS zqir{XC`vmxJ%k%R;qn}h5SiUpZ$K_P_F pxFNbIr9DtznyvM$m=HE$HYesJ3$kByyd{(a4>vE@k`=+b{tcn$%3c5f diff --git a/palettes/WXtoImg-sea.png b/palettes/WXtoImg-sea.png deleted file mode 100644 index d92837a0128b19ef95bf3445cfd44110bc813b94..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4942 zcmcIo2~<E6wB9qS;->FYcHPoq z4fdIvoUaSJGOBQD@>Qu~(`v;2e^wT%Z?BQf2Xe9K__(*-_#ts}(hOb9cSpyE^U4oo zvh(-ro>slTQ;=`V0`uRNqN`BS4%ZPN0xg$-RwK9*&B0Z4y4rmf#q+>3!2h-cid?=@ zTZS%qI5X;@dpZuSbbL25MomZo9OIXGwipMqM9VuxUd>iW1ZSL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|j{@s~F;Ryb z#NdR|Lx@aP0EfL@Jp|CQ^(nsYaG2 z#zcp$ZtpKr;TH|C3eoVVa~YO?h#CVRg8F1reX@xg#n_T+W=S>IB~vWPN^sAHs+d84b+L8B^i0 zuwNF@vu8oS_%T8mEG~#((AA?1;HMWLhd>)SjPOVX%P$sCjLZxu|VX^}K*`ed>9ZNsW^EDJ)j279z%z}JjA++q%JWx4s z5!0s_n3$0_e4`6L2QAvLl^#ai$P8fs7RACKj1@@B+};Z@MZ`WAdPD@#E|Rlo0>#AA zn9Ohw{RzUP-(hGVhYQGNpF>18MSN~#f`lkuy%-6qJR. - * - */ - -#ifndef APT_H -#define APT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(__GNUC__) && (__GNUC__ >= 4) -#define APT_API __attribute__((visibility("default"))) -#elif defined(_MSC_VER) -#ifdef APT_API_EXPORT -#define APT_API __declspec(dllexport) -#elif APT_API_STATIC -#define APT_API -#else if -#define APT_API __declspec(dllimport) -#endif -#else -#define APT_API -#endif - -// Maximum height of an APT image in number of rows -#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) -// Offset in pixels to channel B -#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) - -// Number of rows required for apt_calibrate -#define APT_CALIBRATION_ROWS 192 -// Channel ID returned by apt_calibrate -// NOAA-15: https://nssdc.gsfc.nasa.gov/nmc/experiment/display.action?id=1998-030A-01 -// Channel 1: visible (0.58-0.68 um) -// Channel 2: near-IR (0.725-1.0 um) -// Channel 3A: near-IR (1.58-1.64 um) -// Channel 3B: mid-infrared (3.55-3.93 um) -// Channel 4: thermal-infrared (10.3-11.3 um) -// Channel 5: thermal-infrared (11.5-12.5 um) -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; - -// 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); - -typedef struct { - float *prow[APT_MAX_HEIGHT]; // Row buffers - int nrow; // Number of rows - int zenith; // Row in image where satellite reaches peak elevation - apt_channel_t chA, chB; // ID of each channel - char name[256]; // Stripped filename - char *palette; // Filename of palette -} apt_image_t; - -typedef struct { - float r, g, b; -} apt_rgb_t; - -int APT_API apt_init(double sample_rate); -int APT_API apt_getpixelrow(float *pixelv, int nrow, int *zenith, int reset, apt_getsamples_t getsamples, void *context); - -void APT_API apt_histogramEqualise(float **prow, int nrow, int offset, int width); -void APT_API apt_linearEnhance(float **prow, int nrow, int offset, int width); -apt_channel_t APT_API apt_calibrate(float **prow, int nrow, int offset, int width); -void APT_API apt_denoise(float **prow, int nrow, int offset, int width); -void APT_API apt_flipImage(apt_image_t *img, int width, int offset); -int APT_API apt_cropNoise(apt_image_t *img); -void APT_API apt_calibrate_thermal(int satnum, apt_image_t *img, int offset, int width); -void APT_API apt_calibrate_visible(int satnum, apt_image_t *img, int offset, int width); -// Moved to apt_calibrate_thermal -#define apt_temperature apt_calibrate_thermal - -apt_rgb_t APT_API apt_applyPalette(char *palette, int val); -apt_rgb_t APT_API apt_RGBcomposite(apt_rgb_t top, float top_a, apt_rgb_t bottom, float bottom_a); - -extern char APT_API apt_TempPalette[256 * 3]; -extern char APT_API apt_PrecipPalette[58 * 3]; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/argparse b/src/argparse deleted file mode 160000 index c612dc0..0000000 --- a/src/argparse +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c612dc03958cdbd538ca306d61853b643a435933 diff --git a/src/calibration.c b/src/calibration.c deleted file mode 100644 index e5b32fa..0000000 --- a/src/calibration.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2019-2022 Xerbo (xerbo@protonmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "calibration.h" - -#include "util.h" - -const calibration_t calibration[3] = {{.name = "NOAA-15", - .prt = - { - {1.36328e-06f, 0.051045f, 276.60157f}, // PRT 1 - {1.47266e-06f, 0.050909f, 276.62531f}, // PRT 2 - {1.47656e-06f, 0.050907f, 276.67413f}, // PRT 3 - {1.47656e-06f, 0.050966f, 276.59258f} // PRT 4 - }, - .visible = {{.low = {0.0568f, -2.1874f}, .high = {0.1633f, -54.9928f}, .cutoff = 496.0f}, - {.low = {0.0596f, -2.4096f}, .high = {0.1629f, -55.2436f}, .cutoff = 511.0f}}, - .rad = - { - {925.4075f, 0.337810f, 0.998719f}, // Channel 4 - {839.8979f, 0.304558f, 0.999024f}, // Channel 5 - {2695.9743f, 1.621256f, 0.998015f} // Channel 3B - }, - .cor = - { - {-4.50f, {0.0004524f, -0.0932f, 4.76f}}, // Channel 4 - {-3.61f, {0.0002811f, -0.0659f, 3.83f}}, // Channel 5 - {0.0f, {0.0f, 0.0f, 0.0f}} // Channel 3B - }}, - {.name = "NOAA-18", - .prt = - { - {1.657e-06f, 0.05090f, 276.601f}, // PRT 1 - {1.482e-06f, 0.05101f, 276.683f}, // PRT 2 - {1.313e-06f, 0.05117f, 276.565f}, // PRT 3 - {1.484e-06f, 0.05103f, 276.615f} // PRT 4 - }, - .visible = {{.low = {0.06174f, -2.434f}, .high = {0.1841f, -63.31f}, .cutoff = 501.54f}, - {.low = {0.07514f, -2.960f}, .high = {0.2254f, -78.55f}, .cutoff = 500.40f}}, - .rad = - { - {928.1460f, 0.436645f, 0.998607f}, // Channel 4 - {833.2532f, 0.253179f, 0.999057f}, // Channel 5 - {2659.7952f, 1.698704f, 0.996960f} // Channel 3B - }, - .cor = - { - {-5.53f, {0.00052337f, -0.11069f, 5.82f}}, // Channel 4 - {-2.22f, {0.00017715f, -0.04360f, 2.67f}}, // Channel 5 - {0.0f, {0.0f, 0.0f, 0.0f}} // Channel 3B - }}, - {.name = "NOAA-19", - .prt = - { - {1.405783e-06f, 0.051111f, 276.6067f}, // PRT 1 - {1.496037e-06f, 0.051090f, 276.6119f}, // PRT 2 - {1.496990e-06f, 0.051033f, 276.6311f}, // PRT 3 - {1.493110e-06f, 0.051058f, 276.6268f} // PRT 4 - }, - .visible = {{.low = {0.05555f, -2.159f}, .high = {0.1639f, -56.33f}, .cutoff = 496.43f}, - {.low = {0.06614f, -2.565f}, .high = {0.1970f, -68.01f}, .cutoff = 500.37f}}, - .rad = - { - {928.9f, 0.53959f, 0.998534f}, // Channel 4 - {831.9f, 0.36064f, 0.998913f}, // Channel 5 - {2670.0f, 1.67396f, 0.997364f} // Channel 3B - }, - .cor = { - {-5.49f, {0.00054668f, -0.11187f, 5.70f}}, // Channel 4 - {-3.39f, {0.00024985f, -0.05991f, 3.58f}}, // Channel 5 - {0.0f, {0.0f, 0.0f, 0.0f}} // Channel 3B - }}}; - -calibration_t get_calibration(int satid) { - switch (satid) { - case 15: - return calibration[0]; - case 18: - return calibration[1]; - case 19: - return calibration[2]; - default: - error("Invalid satid in get_calibration()"); /* following is only to shut up the compiler */ - return calibration[0]; - } -} diff --git a/src/color.c b/src/color.c deleted file mode 100644 index 50401c4..0000000 --- a/src/color.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This file is part of Aptdec. - * Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 2019-2022 - * - * Aptdec is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "color.h" - -#include "apt.h" - -apt_rgb_t apt_applyPalette(char *palette, int val) { - return (apt_rgb_t){palette[(int)CLIP(val, 0, 255) * 3 + 0], palette[(int)CLIP(val, 0, 255) * 3 + 1], - palette[(int)CLIP(val, 0, 255) * 3 + 2]}; -} - -apt_rgb_t apt_RGBcomposite(apt_rgb_t top, float top_a, apt_rgb_t bottom, float bottom_a) { - return (apt_rgb_t){MCOMPOSITE(top.r, top_a, bottom.r, bottom_a), MCOMPOSITE(top.g, top_a, bottom.g, bottom_a), - MCOMPOSITE(top.b, top_a, bottom.b, bottom_a)}; -} - -// The "I totally didn't just steal this from WXtoImg" palette -char apt_TempPalette[256 * 3] = { - "\x45\x0\x8f\x46\x0\x91\x47\x0\x92\x48\x0\x94\x49\x0\x96\x4a\x0\x98\x4b\x0\x9b\x4d\x0\x9d" - "\x4e\x0\xa0\x50\x0\xa2\x51\x0\xa5\x52\x0\xa7\x54\x0\xaa\x56\x0\xae\x57\x0\xb1" - "\x58\x0\xb4\x5a\x0\xb7\x5c\x0\xba\x5e\x0\xbd\x5f\x0\xc0\x61\x0\xc4\x64\x0\xc8" - "\x66\x0\xcb\x68\x0\xce\x69\x0\xd1\x68\x0\xd4\x65\x0\xd7\x63\x0\xda\x61\x0\xdd" - "\x5d\x0\xe1\x5b\x0\xe4\x59\x0\xe6\x56\x0\xe9\x53\x0\xeb\x50\x0\xee\x4d\x0\xf0" - "\x49\x0\xf3\x47\x0\xfc\x43\x0\xfa\x31\x0\xbf\x20\x0\x89\x20\x0\x92\x1e\x0\x95" - "\x1b\x0\x97\x19\x0\x9a\x17\x0\x9c\x15\x0\x9e\x12\x0\xa0\xf\x0\xa3\xf\x2\xa5" - "\xe\x6\xa8\xe\xa\xab\xe\xd\xad\xe\x11\xb1\xd\x15\xb4\xd\x18\xb7\xd\x1c\xba" - "\xb\x21\xbd\xa\x25\xc0\xa\x29\xc3\x9\x2d\xc6\x8\x33\xca\x7\x36\xcd\x7\x3b\xd0" - "\x7\x41\xd3\x5\x45\xd6\x4\x4b\xd9\x4\x50\xdc\x3\x55\xde\x2\x5d\xe2\x1\x61\xe5" - "\x0\x66\xe7\x0\x6c\xea\x0\x72\xec\x0\x78\xee\x0\x7d\xf0\x0\x82\xf3\x0\x8d\xfc" - "\x0\x90\xfa\x0\x71\xbf\x0\x54\x89\x0\x5c\x91\x0\x61\x94\x0\x64\x96\x0\x68\x97" - "\x0\x6d\x99\x0\x71\x9b\x0\x75\x9d\x0\x79\x9f\x0\x7e\xa0\x0\x82\xa2\x0\x87\xa4" - "\x0\x8c\xa6\x0\x92\xaa\x0\x96\xac\x0\x9c\xae\x0\xa2\xb1\x0\xa6\xb3\x0\xaa\xb5" - "\x0\xad\xb7\x0\xb1\xba\x0\xb6\xbe\x0\xba\xc0\x0\xbe\xc2\x0\xc2\xc5\x0\xc6\xc6" - "\x0\xca\xc9\x0\xcc\xca\x0\xcf\xcb\x0\xd2\xcc\x0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x9a\x70\x0\x9c\x6e\x0\x9e\x6d\x0\xa0\x6b\x0\xa3\x6a\x0\xa5\x68\x0\xa8\x67\x0" - "\xab\x66\x0\xae\x65\x0\xb2\x63\x0\xb4\x61\x0\xb7\x5f\x0\xba\x5d\x0\xbd\x5c\x0" - "\xc0\x59\x0\xc3\x57\x0\xc6\x54\x0\xca\x50\x0\xcd\x4d\x0\xd0\x4a\x0\xd3\x47\x0" - "\xd6\x43\x0\xd9\x40\x0\xdc\x3d\x0\xde\x39\x0\xe2\x33\x0\xe5\x2f\x0\xe7\x2c\x0" - "\xea\x28\x0\xec\x23\x0\xef\x1f\x0\xf1\x1a\x0\xf3\x14\x0\xfb\xf\x0\xfa\xd\x0" - "\xc1\x5\x0\x8e\x0\x0\x97\x0\x0\x9b\x0\x0\x9e\x0\x0\xa1\x0\x0\xa5\x0\x0" - "\xa9\x0\x0\xad\x0\x0\xb1\x0\x0\xb6\x0\x0\xba\x0\x0\xbd\x0\x0\xc2\x0\x0" - "\xc8\x0\x0\xcc\x0\x0\xcc\x0\x0"}; - -char apt_PrecipPalette[58 * 3] = { - "\x8\x89\x41\x0\xc5\x44\x0\xd1\x2c\x0\xe3\x1c\x0\xf9\x6\x14\xff\x0\x3e\xff\x0\x5d\xff\x0" - "\x80\xff\x0\xab\xff\x0\xcd\xfe\x0\xf8\xff\x0\xff\xe6\x0\xff\xb8\x0\xff\x98\x0" - "\xff\x75\x0\xff\x49\x0\xfe\x26\x0\xff\x4\x0\xdf\x0\x0\xa8\x0\x0\x87\x0\x0" - "\x5a\x0\x0\x39\x0\x0\x11\x0\x0\xe\x10\x10\x23\x22\x22\x33\x33\x33\x41\x41\x41" - "\x53\x53\x53\x60\x60\x60\x6e\x6e\x6e\x80\x80\x80\x8e\x8e\x8e\xa0\xa0\xa0\xae\xae\xae" - "\xc0\xc0\xc0\xce\xce\xce\xdc\xdc\xdc\xef\xef\xef\xfa\xfa\xfa\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" - "\xff\xff\xff"}; diff --git a/src/color.h b/src/color.h deleted file mode 100644 index 1fc253e..0000000 --- a/src/color.h +++ /dev/null @@ -1,3 +0,0 @@ -#include "common.h" - -#define MCOMPOSITE(m1, a1, m2, a2) (m1 * a1 + m2 * a2 * (1 - a1)) diff --git a/src/common.h b/src/common.h deleted file mode 100644 index 7130d46..0000000 --- a/src/common.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of Aptdec. - * Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 2019-2022 - * - * Aptdec is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -// Constants -#define VERSION "Aptdec; (c) 2004-2009 Thierry Leconte F4DWV, Xerbo (xerbo@protonmail.com) 2019-2022" - -// Useful macros -#define CLIP(v, lo, hi) (v > hi ? hi : (v > lo ? v : lo)) -#define CONTAINS(str, char) (strchr(str, (int)char) != NULL) - -// Typedefs -#ifndef STRUCTS_DEFINED -#define STRUCTS_DEFINED -typedef struct { - char *type; // Output image type - char *effects; // Effects on the image - int satnum; // The satellite number - char *path; // Output directory - int realtime; // Realtime decoding - char *filename; // Output filename - char *palette; // Filename of palette - float gamma; // Gamma -} options_t; - -enum imagetypes { - Raw_Image = 'r', - Palleted = 'p', - Temperature = 't', - Channel_A = 'a', - Channel_B = 'b', - Distribution = 'd', - Visible = 'v' -}; -enum effects { - Crop_Telemetry = 't', - Histogram_Equalise = 'h', - Denoise = 'd', - Precipitation_Overlay = 'p', - Flip_Image = 'f', - Linear_Equalise = 'l', - Crop_Noise = 'c' -}; - -#endif diff --git a/src/dsp.c b/src/dsp.c deleted file mode 100644 index befffe7..0000000 --- a/src/dsp.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2022 Xerbo (xerbo@protonmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include - -#include "apt.h" -#include "filter.h" -#include "taps.h" -#include "util.h" - -// Block sizes -#define BLKAMP 32768 -#define BLKIN 32768 - -#define CARRIER_FREQ 2400.0 -#define MAX_CARRIER_OFFSET 20.0 - -#define RSMULT 15 -#define Fi (APT_IMG_WIDTH * 2 * RSMULT) - -static float _sample_rate; - -static float offset = 0.0; -static float FreqLine = 1.0; - -static float oscillator_freq; -static float pll_alpha; -static float pll_beta; - -// Initalise and configure PLL -int apt_init(double sample_rate) { - if (sample_rate > Fi) return 1; - if (sample_rate < APT_IMG_WIDTH * 2) return -1; - _sample_rate = sample_rate; - - // Pll configuration - pll_alpha = 50 / _sample_rate; - pll_beta = pll_alpha * pll_alpha / 2.0; - oscillator_freq = CARRIER_FREQ / sample_rate; - - return 0; -} - -static float pll(complexf_t in) { - static float oscillator_phase = 0.0; - - // Internal oscillator -#ifdef _MSC_VER - complexf_t osc = _FCbuild(cos(oscillator_phase), -sin(oscillator_phase)); - in = _FCmulcc(in, osc); -#else - complexf_t osc = cos(oscillator_phase) + -sin(oscillator_phase) * I; - in *= osc; -#endif - - // Error detector - float error = cargf(in); - - // Adjust frequency and phase - oscillator_freq += pll_beta * error; - oscillator_freq = clamp_half(oscillator_freq, (CARRIER_FREQ + MAX_CARRIER_OFFSET) / _sample_rate); - oscillator_phase += M_TAUf * (pll_alpha * error + oscillator_freq); - oscillator_phase = remainderf(oscillator_phase, M_TAUf); - - return crealf(in); -} - -// Convert samples into pixels -static int getamp(float *ampbuff, int count, apt_getsamples_t getsamples, void *context) { - static float inbuff[BLKIN]; - static int idxin = 0; - static int nin = 0; - - for (int n = 0; n < count; n++) { - float I2, Q; - - // Get some more samples when needed - if (nin < HILBERT_FILTER_SIZE * 2 + 2) { - // Number of samples read - int res; - memmove(inbuff, &(inbuff[idxin]), nin * sizeof(float)); - idxin = 0; - - // Read some samples - res = getsamples(context, &(inbuff[nin]), BLKIN - nin); - nin += res; - - // Make sure there is enough samples to continue - if (nin < HILBERT_FILTER_SIZE * 2 + 2) return n; - } - - // Process read samples into a brightness value - complexf_t sample = hilbert_transform(&inbuff[idxin], hilbert_filter, HILBERT_FILTER_SIZE); - ampbuff[n] = pll(sample); - - // Increment current sample - idxin++; - nin--; - } - - return count; -} - -// Sub-pixel offsetting -int getpixelv(float *pvbuff, int count, apt_getsamples_t getsamples, void *context) { - // Amplitude buffer - static float ampbuff[BLKAMP]; - static int nam = 0; - static int idxam = 0; - - float mult; - - // Gaussian resampling factor - mult = (float)Fi / _sample_rate * FreqLine; - int m = (int)(LOW_PASS_SIZE / mult + 1); - - for (int n = 0; n < count; n++) { - int shift; - - if (nam < m) { - int res; - memmove(ampbuff, &(ampbuff[idxam]), nam * sizeof(float)); - idxam = 0; - res = getamp(&(ampbuff[nam]), BLKAMP - nam, getsamples, context); - nam += res; - if (nam < m) return n; - } - - pvbuff[n] = interpolating_convolve(&(ampbuff[idxam]), low_pass, LOW_PASS_SIZE, offset, mult) * mult * 256.0; - - shift = ((int)floor((RSMULT - offset) / mult)) + 1; - offset = shift * mult + offset - RSMULT; - - idxam += shift; - nam -= shift; - } - - return count; -} - -// Get an entire row of pixels, aligned with sync markers -int apt_getpixelrow(float *pixelv, int nrow, int *zenith, int reset, apt_getsamples_t getsamples, void *context) { - static float pixels[APT_IMG_WIDTH + SYNC_PATTERN_SIZE]; - static size_t npv; - static int synced = 0; - static float max = 0.0; - static float minDoppler = 1000000000, previous = 0; - - if (reset) synced = 0; - - float corr, ecorr, lcorr; - int res; - - // Move the row buffer into the the image buffer - if (npv > 0) memmove(pixelv, pixels, npv * sizeof(float)); - - // Get the sync line - if (npv < SYNC_PATTERN_SIZE + 2) { - res = getpixelv(&(pixelv[npv]), SYNC_PATTERN_SIZE + 2 - npv, getsamples, context); - npv += res; - if (npv < SYNC_PATTERN_SIZE + 2) return 0; - } - - // Calculate the frequency offset - ecorr = convolve(pixelv, sync_pattern, SYNC_PATTERN_SIZE); - corr = convolve(&pixelv[1], sync_pattern, SYNC_PATTERN_SIZE - 1); - lcorr = convolve(&pixelv[2], sync_pattern, SYNC_PATTERN_SIZE - 2); - FreqLine = 1.0 + ((ecorr - lcorr) / corr / APT_IMG_WIDTH / 4.0); - - float val = fabs(lcorr - ecorr) * 0.25 + previous * 0.75; - if (val < minDoppler && nrow > 10) { - minDoppler = val; - *zenith = nrow; - } - previous = fabs(lcorr - ecorr); - - // The point in which the pixel offset is recalculated - if (corr < 0.75 * max) { - synced = 0; - FreqLine = 1.0; - } - max = corr; - - if (synced < 8) { - int mshift; - static int lastmshift; - - if (npv < APT_IMG_WIDTH + SYNC_PATTERN_SIZE) { - res = getpixelv(&(pixelv[npv]), APT_IMG_WIDTH + SYNC_PATTERN_SIZE - npv, getsamples, context); - npv += res; - if (npv < APT_IMG_WIDTH + SYNC_PATTERN_SIZE) return 0; - } - - // Test every possible position until we get the best result - mshift = 0; - for (int shift = 0; shift < APT_IMG_WIDTH; shift++) { - float corr; - - corr = convolve(&(pixelv[shift + 1]), sync_pattern, SYNC_PATTERN_SIZE); - if (corr > max) { - mshift = shift; - max = corr; - } - } - - // Stop rows dissapearing into the void - int mshiftOrig = mshift; - if (abs(lastmshift - mshift) > 3 && nrow != 0) { - mshift = 0; - } - lastmshift = mshiftOrig; - - // If we are already as aligned as we can get, just continue - if (mshift == 0) { - synced++; - } else { - memmove(pixelv, &(pixelv[mshift]), (npv - mshift) * sizeof(float)); - npv -= mshift; - synced = 0; - FreqLine = 1.0; - } - } - - // Get the rest of this row - if (npv < APT_IMG_WIDTH) { - res = getpixelv(&(pixelv[npv]), APT_IMG_WIDTH - npv, getsamples, context); - npv += res; - if (npv < APT_IMG_WIDTH) return 0; - } - - // Move the sync lines into the output buffer with the calculated offset - if (npv == APT_IMG_WIDTH) { - npv = 0; - } else { - memmove(pixels, &(pixelv[APT_IMG_WIDTH]), (npv - APT_IMG_WIDTH) * sizeof(float)); - npv -= APT_IMG_WIDTH; - } - - return 1; -} diff --git a/src/filter.c b/src/filter.c deleted file mode 100644 index 06746aa..0000000 --- a/src/filter.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2022 Xerbo (xerbo@protonmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "filter.h" - -#include - -#include "util.h" - -float convolve(const float *in, const float *taps, size_t len) { - float sum = 0.0; - for (size_t i = 0; i < len; i++) { - sum += in[i] * taps[i]; - } - - return sum; -} - -complexf_t hilbert_transform(const float *in, const float *taps, size_t len) { - float i = 0.0; - float q = 0.0; - - for (size_t k = 0; k < len; k++) { - q += in[2 * k] * taps[k]; - i += in[2 * k]; - } - - i = in[len - 1] - (i / len); -#ifdef _MSC_VER - return _FCbuild(i, q); -#else - return i + q * I; -#endif -} - -float interpolating_convolve(const float *in, const float *taps, size_t len, float offset, float delta) { - float out = 0.0; - float n = offset; - - for (size_t i = 0; i < (len - 1) / delta - 1; n += delta, i++) { - int k = (int)floor(n); - float alpha = n - k; - - out += in[i] * (taps[k] * (1.0f - alpha) + taps[k + 1] * alpha); - } - return out; -} diff --git a/src/image.c b/src/image.c deleted file mode 100644 index 8c9cbc9..0000000 --- a/src/image.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * This file is part of Aptdec. - * Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 2019-2022 - * - * Aptdec is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "image.h" - -#include -#include -#include -#include - -#include "algebra.h" -#include "apt.h" -#include "util.h" - -static linear_t compute_regression(float *wedges) { - // { 0.106, 0.215, 0.324, 0.433, 0.542, 0.652, 0.78, 0.87, 0.0 } - const float teleramp[9] = {31.07, 63.02, 94.96, 126.9, 158.86, 191.1, 228.62, 255.0, 0.0}; - - return linear_regression(wedges, teleramp, 9); -} - -static float tele[16]; -static float Cs; - -void apt_histogramEqualise(float **prow, int nrow, int offset, int width) { - // Plot histogram - int histogram[256] = {0}; - for (int y = 0; y < nrow; y++) - for (int x = 0; x < width; x++) histogram[(int)CLIP(prow[y][x + offset], 0, 255)]++; - - // Calculate cumulative frequency - long sum = 0, cf[256] = {0}; - for (int i = 0; i < 255; i++) { - sum += histogram[i]; - cf[i] = sum; - } - - // Apply histogram - int area = nrow * width; - for (int y = 0; y < nrow; y++) { - for (int x = 0; x < width; x++) { - int k = (int)prow[y][x + offset]; - prow[y][x + offset] = (256.0f / area) * cf[k]; - } - } -} - -void apt_linearEnhance(float **prow, int nrow, int offset, int width) { - // Plot histogram - int histogram[256] = {0}; - for (int y = 0; y < nrow; y++) - for (int x = 0; x < width; x++) histogram[(int)CLIP(prow[y][x + offset], 0, 255)]++; - - // Find min/max points - int min = -1, max = -1; - for (int i = 5; i < 250; i++) { - if (histogram[i] / width / (nrow / 255.0) > 0.1) { - if (min == -1) min = i; - max = i; - } - } - - // Stretch the brightness into the new range - for (int y = 0; y < nrow; y++) { - for (int x = 0; x < width; x++) { - prow[y][x + offset] = (prow[y][x + offset] - min) / (max - min) * 255.0f; - prow[y][x + offset] = CLIP(prow[y][x + offset], 0.0f, 255.0f); - } - } -} - -// Brightness calibrate, including telemetry -void calibrateImage(float **prow, int nrow, int offset, int width, linear_t regr) { - offset -= APT_SYNC_WIDTH + APT_SPC_WIDTH; - - for (int y = 0; y < nrow; y++) { - for (int x = 0; x < width + APT_SYNC_WIDTH + APT_SPC_WIDTH + APT_TELE_WIDTH; x++) { - float pv = linear_calc(prow[y][x + offset], regr); - prow[y][x + offset] = CLIP(pv, 0, 255); - } - } -} - -float teleNoise(float *wedges) { - float pattern[9] = {31.07, 63.02, 94.96, 126.9, 158.86, 191.1, 228.62, 255.0, 0.0}; - float noise = 0; - for (int i = 0; i < 9; i++) noise += fabs(wedges[i] - pattern[i]); - - return noise; -} - -// Get telemetry data for thermal calibration -apt_channel_t apt_calibrate(float **prow, int nrow, int offset, int width) { - float teleline[APT_MAX_HEIGHT] = {0.0}; - float wedge[16]; - linear_t regr[APT_MAX_HEIGHT / APT_FRAME_LEN + 1]; - int telestart, mtelestart = 0; - int channel = -1; - - // The minimum rows required to decode a full frame - if (nrow < APT_CALIBRATION_ROWS) { - error_noexit("Telemetry decoding error, not enough rows"); - return APT_CHANNEL_UNKNOWN; - } - - // Calculate average of a row of telemetry - for (int y = 0; y < nrow; y++) { - for (int x = 3; x < 43; x++) teleline[y] += prow[y][x + offset + width]; - - teleline[y] /= 40.0; - } - - /* Wedge 7 is white and 8 is black, this will have the largest - * difference in brightness, this can be used to find the current - * position within the telemetry. - */ - float max = 0.0f; - for (int n = nrow / 3 - 64; n < 2 * nrow / 3 - 64; n++) { - float df; - - // (sum 4px below) - (sum 4px above) - df = (float)((teleline[n - 4] + teleline[n - 3] + teleline[n - 2] + teleline[n - 1]) - - (teleline[n + 0] + teleline[n + 1] + teleline[n + 2] + teleline[n + 3])); - - // Find the maximum difference - if (df > max) { - mtelestart = n; - max = df; - } - } - - telestart = (mtelestart + 64) % APT_FRAME_LEN; - - // Make sure that theres at least one full frame in the image - if (nrow < telestart + APT_FRAME_LEN) { - error_noexit("Telemetry decoding error, not enough rows"); - return APT_CHANNEL_UNKNOWN; - } - - // Find the least noisy frame - float minNoise = -1; - int bestFrame = -1; - for (int n = telestart, k = 0; n < nrow - APT_FRAME_LEN; n += APT_FRAME_LEN, k++) { - int j; - - for (j = 0; j < 16; j++) { - int i; - - wedge[j] = 0.0; - for (i = 1; i < 7; i++) wedge[j] += teleline[n + j * 8 + i]; - wedge[j] /= 6; - } - - float noise = teleNoise(wedge); - if (noise < minNoise || minNoise == -1) { - minNoise = noise; - bestFrame = k; - - // Compute & apply regression on the wedges - regr[k] = compute_regression(wedge); - for (int j = 0; j < 16; j++) tele[j] = linear_calc(wedge[j], regr[k]); - - /* Compare the channel ID wedge to the reference - * wedges, the wedge with the closest match will - * be the channel ID - */ - float min = -1; - for (int j = 0; j < 6; j++) { - float df = (float)(tele[15] - tele[j]); - df *= df; - - if (df < min || min == -1) { - channel = j; - min = df; - } - } - - // Find the brightness of the minute marker, I don't really know what for - Cs = 0.0; - int i, j = n; - for (i = 0, j = n; j < n + APT_FRAME_LEN; j++) { - float csline = 0.0; - for (int l = 3; l < 43; l++) csline += prow[n][l + offset - APT_SPC_WIDTH]; - csline /= 40.0; - - if (csline > 50.0) { - Cs += csline; - i++; - } - } - Cs = linear_calc((Cs / i), regr[k]); - } - } - - if (bestFrame == -1) { - error_noexit("Something has gone very wrong, please file a bug report"); - return APT_CHANNEL_UNKNOWN; - } - - calibrateImage(prow, nrow, offset, width, regr[bestFrame]); - - return (apt_channel_t)(channel + 1); -} - -extern float quick_select(float arr[], int n); - -// Biased median denoise, pretyt ugly -#define TRIG_LEVEL 40 -void apt_denoise(float **prow, int nrow, int offset, int width) { - for (int y = 2; y < nrow - 2; y++) { - for (int x = offset + 1; x < offset + width - 1; x++) { - if (prow[y][x + 1] - prow[y][x] > TRIG_LEVEL || prow[y][x - 1] - prow[y][x] > TRIG_LEVEL || - prow[y + 1][x] - prow[y][x] > TRIG_LEVEL || prow[y - 1][x] - prow[y][x] > TRIG_LEVEL) { - prow[y][x] = quick_select((float[]){prow[y + 2][x - 1], prow[y + 2][x], prow[y + 2][x + 1], prow[y + 1][x - 1], - prow[y + 1][x], prow[y + 1][x + 1], prow[y - 1][x - 1], prow[y - 1][x], - prow[y - 1][x + 1], prow[y - 2][x - 1], prow[y - 2][x], prow[y - 2][x + 1]}, - 12); - } - } - } -} -#undef TRIG_LEVEL - -// Flips a channel, for northbound passes -void apt_flipImage(apt_image_t *img, int width, int offset) { - for (int y = 1; y < img->nrow; y++) { - for (int x = 1; x < ceil(width / 2.0); x++) { - // Flip top-left & bottom-right - float buffer = img->prow[img->nrow - y][offset + x]; - img->prow[img->nrow - y][offset + x] = img->prow[y][offset + (width - x)]; - img->prow[y][offset + (width - x)] = buffer; - } - } -} - -// Calculate crop to reomve noise from the start and end of an image -int apt_cropNoise(apt_image_t *img) { -#define NOISE_THRESH 180.0 - - // Average value of minute marker - float spc_rows[APT_MAX_HEIGHT] = {0.0}; - int startCrop = 0; - int endCrop = img->nrow; - for (int y = 0; y < img->nrow; y++) { - for (int x = 0; x < APT_SPC_WIDTH; x++) { - spc_rows[y] += img->prow[y][x + (APT_CHB_OFFSET - APT_SPC_WIDTH)]; - } - spc_rows[y] /= APT_SPC_WIDTH; - - // Skip minute markings - if (spc_rows[y] < 10) { - spc_rows[y] = spc_rows[y - 1]; - } - } - - // 3 row average - for (int y = 0; y < img->nrow; y++) { - spc_rows[y] = (spc_rows[y + 1] + spc_rows[y + 2] + spc_rows[y + 3]) / 3; - // img.prow[y][0] = spc_rows[y]; - } - - // Find ends - for (int y = 0; y < img->nrow - 1; y++) { - if (spc_rows[y] > NOISE_THRESH) { - endCrop = y; - } - } - for (int y = img->nrow; y > 0; y--) { - if (spc_rows[y] > NOISE_THRESH) { - startCrop = y; - } - } - - // printf("Crop rows: %i -> %i\n", startCrop, endCrop); - - // 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) * APT_PROW_WIDTH); - } - - // Ignore the noisy rows at the end - img->nrow = (endCrop - startCrop); - - return startCrop; -} - -// --- Visible and Temperature Calibration --- // -#include "calibration.h" - -typedef struct { - float Nbb; - float Cs; - float Cb; - int ch; -} tempparam_t; - -// IR channel temperature compensation -tempparam_t tempcomp(float t[16], int ch, int satnum) { - tempparam_t tpr; - tpr.ch = ch - 4; - - const calibration_t calibration = get_calibration(satnum); - const float Vc = calibration.rad[tpr.ch].vc; - const float A = calibration.rad[tpr.ch].A; - const float B = calibration.rad[tpr.ch].B; - - // Compute PRT temperature - float T[4]; - for (size_t n = 0; n < 4; n++) { - T[n] = quadratic_calc(t[n + 9] * 4.0, calibration.prt[n]); - } - - float Tbb = (T[0] + T[1] + T[2] + T[3]) / 4.0; // Blackbody temperature - float Tbbstar = A + Tbb * B; // Effective blackbody temperature - - tpr.Nbb = C1 * pow(Vc, 3) / (expf(C2 * Vc / Tbbstar) - 1.0f); // Blackbody radiance - - tpr.Cs = 246.4 * 4.0; // FIXME - tpr.Cb = t[14] * 4.0; - return tpr; -} - -// IR channel temperature calibration -static float tempcal(float Ce, int satnum, tempparam_t tpr) { - const calibration_t calibration = get_calibration(satnum); - const float Ns = calibration.cor[tpr.ch].Ns; - const float Vc = calibration.rad[tpr.ch].vc; - const float A = calibration.rad[tpr.ch].A; - const float B = calibration.rad[tpr.ch].B; - - float Nl = Ns + (tpr.Nbb - Ns) * (tpr.Cs - Ce * 4.0) / (tpr.Cs - tpr.Cb); // Linear radiance estimate - float Nc = quadratic_calc(Nl, calibration.cor[tpr.ch].quadratic); // Non-linear correction - float Ne = Nl + Nc; // Corrected radiance - - float Testar = C2 * Vc / logf(C1 * powf(Vc, 3) / Ne + 1.0); // Equivlent black body temperature - float Te = (Testar - A) / B; // Temperature (kelvin) - - // Convert to celsius - Te -= 273.15; - // Rescale to 0-255 for -100°C to +60°C - return (Te + 100.0) / 160.0 * 255.0; -} - -// Temperature calibration wrapper -void apt_calibrate_thermal(int satnum, apt_image_t *img, int offset, int width) { - tempparam_t temp = tempcomp(tele, img->chB, satnum); - - for (int y = 0; y < img->nrow; y++) { - for (int x = 0; x < width; x++) { - img->prow[y][x + offset] = (float)tempcal(img->prow[y][x + offset], satnum, temp); - } - } -} - -float calibrate_pixel(float value, int channel, calibration_t cal) { - if (value > cal.visible[channel].cutoff) { - return linear_calc(value * 4.0f, cal.visible[channel].high) * 255.0f / 100.0f; - } else { - return linear_calc(value * 4.0f, cal.visible[channel].low) * 255.0f / 100.0f; - } -} - -void apt_calibrate_visible(int satnum, apt_image_t *img, int offset, int width) { - const calibration_t calibration = get_calibration(satnum); - int channel = img->chA - 1; - - for (int y = 0; y < img->nrow; y++) { - for (int x = 0; x < width; x++) { - img->prow[y][x + offset] = clamp(calibrate_pixel(img->prow[y][x + offset], channel, calibration), 255.0f, 0.0f); - } - } -} diff --git a/src/image.h b/src/image.h deleted file mode 100644 index 94d52eb..0000000 --- a/src/image.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "apt.h" -#include "common.h" diff --git a/src/libs/median.c b/src/libs/median.c deleted file mode 100644 index 2d4e510..0000000 --- a/src/libs/median.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This Quickselect routine is based on the algorithm described in - * "Numerical recipes in C", Second Edition, - * Cambridge University Press, 1992, Section 8.5, ISBN 0-521-43108-5 - * This code by Nicolas Devillard - 1998. Public domain. - */ - -#define ELEM_SWAP(a, b) { register float t = (a); (a) = (b); (b) = t; } -float quick_select(float arr[], int n) { - int low, median, high; - int middle, ll, hh; - - low = 0; high = n-1; median = (low + high) / 2; - for (;;) { - if (high <= low) /* One element only */ - return arr[median] ; - - if (high == low + 1) { /* Two elements only */ - if (arr[low] > arr[high]) - ELEM_SWAP(arr[low], arr[high]); - return arr[median]; - } - - /* Find median of low, middle and high items; swap into position low */ - middle = (low + high) / 2; - if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]); - if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]); - if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]); - - /* Swap low item (now in position middle) into position (low+1) */ - ELEM_SWAP(arr[middle], arr[low+1]); - - /* Nibble from each end towards middle, swapping items when stuck */ - ll = low + 1; - hh = high; - for (;;) { - do ll++; while (arr[low] > arr[ll]); - do hh--; while (arr[hh] > arr[low]); - - if (hh < ll) - break; - - ELEM_SWAP(arr[ll], arr[hh]); - } - - /* Swap middle item (in position low) back into correct position */ - ELEM_SWAP(arr[low], arr[hh]); - - /* Re-set active partition */ - if (hh <= median) - low = ll; - if (hh >= median) - high = hh - 1; - } -} -#undef ELEM_SWAP diff --git a/src/main.c b/src/main.c deleted file mode 100644 index 1ebc488..0000000 --- a/src/main.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * This file is part of Aptdec. - * Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 2019-2022 - * - * Aptdec is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include -#include -#include -#ifndef _MSC_VER -#include -#else -#include -#endif -#include -#include -#include -#include - -#include "apt.h" -#include "argparse/argparse.h" -#include "color.h" -#include "common.h" -#include "image.h" -#include "pngio.h" -#include "util.h" - -// Audio file -static SNDFILE *audioFile; -// Number of channels in audio file -int channels = 1; - -// Function declarations -static int initsnd(char *filename); -int getsamples(void *context, float *samples, int nb); -static int processAudio(char *filename, options_t *opts); - -#ifdef _MSC_VER -// Functions not supported by MSVC -static char *dirname(char *path) { - static char dir[MAX_PATH]; - _splitpath(path, NULL, dir, NULL, NULL); - return dir; -} - -static char *basename(char *path) { - static char base[MAX_PATH]; - _splitpath(path, NULL, NULL, base, NULL); - return base; -} -#endif - -int main(int argc, const char **argv) { - options_t opts = { - .type = "r", .effects = "", .satnum = 19, .path = ".", .realtime = 0, .filename = "", .palette = "", .gamma = 1.0}; - - static const char *const usages[] = { - "aptdec [options] [[--] sources]", - "aptdec [sources]", - NULL, - }; - - struct argparse_option options[] = { - OPT_HELP(), - OPT_GROUP("Image options"), - OPT_STRING('i', "image", &opts.type, "set output image type (see the README for a list)", NULL, 0, 0), - OPT_STRING('e', "effect", &opts.effects, "add an effect (see the README for a list)", NULL, 0, 0), - OPT_FLOAT('g', "gamma", &opts.gamma, "gamma adjustment (1.0 = off)", NULL, 0, 0), - - OPT_GROUP("Satellite options"), - OPT_INTEGER('s', "satellite", &opts.satnum, "satellite ID, must be between 15 and 19", NULL, 0, 0), - - OPT_GROUP("Paths"), - OPT_STRING('p', "palette", &opts.palette, "path to a palette", NULL, 0, 0), - OPT_STRING('o', "filename", &opts.filename, "filename of the output image", NULL, 0, 0), - OPT_STRING('d', "output", &opts.path, "output directory (must exist first)", NULL, 0, 0), - - OPT_GROUP("Misc"), - OPT_BOOLEAN('r', "realtime", &opts.realtime, "decode in realtime", NULL, 0, 0), - OPT_END(), - }; - - struct argparse argparse; - argparse_init(&argparse, options, usages, 0); - argparse_describe( - &argparse, "\nA lightweight FOSS NOAA APT satellite imagery decoder.", - "\nSee `README.md` for a full description of command line arguments and `LICENSE` for licensing conditions."); - argc = argparse_parse(&argparse, argc, argv); - - if (argc == 0) { - argparse_usage(&argparse); - } - - // Actually decode the files - for (int i = 0; i < argc; i++) { - char *filename = strdup(argv[i]); - processAudio(filename, &opts); - } - - return 0; -} - -static int processAudio(char *filename, options_t *opts) { - // Image info struct - apt_image_t img; - - // Mapping between wedge value and channel ID - static struct { - char *id[7]; - char *name[7]; - } ch = {{"?", "1", "2", "3A", "4", "5", "3B"}, - {"unknown", "visble", "near-infrared", "near-infrared", "thermal-infrared", "thermal-infrared", "mid-infrared"}}; - - // Buffer for image channel - char desc[60]; - - // Parse file path - char path[256], extension[32]; - strcpy(path, filename); - strcpy(path, dirname(path)); - sscanf(basename(filename), "%255[^.].%31s", img.name, extension); - - if (opts->realtime) { - // Set output filename to current time when in realtime mode - time_t t; - time(&t); - strncpy(img.name, ctime(&t), 24); - - // Init a row writer - initWriter(opts, &img, APT_IMG_WIDTH, APT_MAX_HEIGHT, "Unprocessed realtime image", "r"); - } - - if (strcmp(extension, "png") == 0) { - // Read PNG into image buffer - printf("Reading %s\n", filename); - if (readRawImage(filename, img.prow, &img.nrow) == 0) { - exit(EPERM); - } - } else { - // Attempt to open the audio file - if (initsnd(filename) == 0) exit(EPERM); - - // Build image - // 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) * 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) break; - - if (opts->realtime) pushRow(img.prow[img.nrow], APT_IMG_WIDTH); - - fprintf(stderr, "Row: %d\r", img.nrow); - fflush(stderr); - } - - // Close stream - sf_close(audioFile); - } - - if (opts->realtime) closeWriter(); - - printf("Total rows: %d\n", img.nrow); - - // Calibrate - img.chA = apt_calibrate(img.prow, img.nrow, APT_CHA_OFFSET, APT_CH_WIDTH); - img.chB = apt_calibrate(img.prow, img.nrow, APT_CHB_OFFSET, APT_CH_WIDTH); - printf("Channel A: %s (%s)\n", ch.id[img.chA], ch.name[img.chA]); - printf("Channel B: %s (%s)\n", ch.id[img.chB], ch.name[img.chB]); - - // Crop noise from start and end of image - if (CONTAINS(opts->effects, Crop_Noise)) { - img.zenith -= apt_cropNoise(&img); - } - - // Denoise - if (CONTAINS(opts->effects, Denoise)) { - apt_denoise(img.prow, img.nrow, APT_CHA_OFFSET, APT_CH_WIDTH); - apt_denoise(img.prow, img.nrow, APT_CHB_OFFSET, APT_CH_WIDTH); - } - - // Flip, for northbound passes - if (CONTAINS(opts->effects, Flip_Image)) { - apt_flipImage(&img, APT_CH_WIDTH, APT_CHA_OFFSET); - apt_flipImage(&img, APT_CH_WIDTH, APT_CHB_OFFSET); - } - - // Temperature - if (CONTAINS(opts->type, Temperature) && img.chB >= 4) { - // 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) * APT_PROW_WIDTH); - memcpy(tmpimg.prow[i], img.prow[i], sizeof(float) * APT_PROW_WIDTH); - } - - // Perform temperature calibration - apt_calibrate_thermal(opts->satnum, &tmpimg, APT_CHB_OFFSET, APT_CH_WIDTH); - ImageOut(opts, &tmpimg, APT_CHB_OFFSET, APT_CH_WIDTH, "Temperature", Temperature, (char *)apt_TempPalette); - } - - // Visible - if (CONTAINS(opts->type, Visible) && img.chA <= 2) { - // 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) * APT_PROW_WIDTH); - memcpy(tmpimg.prow[i], img.prow[i], sizeof(float) * APT_PROW_WIDTH); - } - - // Perform visible calibration - apt_calibrate_visible(opts->satnum, &tmpimg, APT_CHA_OFFSET, APT_CH_WIDTH); - ImageOut(opts, &tmpimg, APT_CHA_OFFSET, APT_CH_WIDTH, "Visible", Visible, NULL); - } - - // Linear equalise - if (CONTAINS(opts->effects, Linear_Equalise)) { - apt_linearEnhance(img.prow, img.nrow, APT_CHA_OFFSET, APT_CH_WIDTH); - apt_linearEnhance(img.prow, img.nrow, APT_CHB_OFFSET, APT_CH_WIDTH); - } - - // Histogram equalise - if (CONTAINS(opts->effects, Histogram_Equalise)) { - apt_histogramEqualise(img.prow, img.nrow, APT_CHA_OFFSET, APT_CH_WIDTH); - apt_histogramEqualise(img.prow, img.nrow, APT_CHB_OFFSET, APT_CH_WIDTH); - } - - // Raw image - if (CONTAINS(opts->type, Raw_Image)) { - sprintf(desc, "%s (%s) & %s (%s)", ch.id[img.chA], ch.name[img.chA], ch.id[img.chB], ch.name[img.chB]); - ImageOut(opts, &img, 0, APT_IMG_WIDTH, desc, Raw_Image, NULL); - } - - // Palette image - if (CONTAINS(opts->type, Palleted)) { - img.palette = opts->palette; - strcpy(desc, "Palette composite"); - ImageOut(opts, &img, APT_CHA_OFFSET, APT_CH_WIDTH, desc, Palleted, NULL); - } - - // Channel A - if (CONTAINS(opts->type, Channel_A)) { - sprintf(desc, "%s (%s)", ch.id[img.chA], ch.name[img.chA]); - ImageOut(opts, &img, APT_CHA_OFFSET, APT_CH_WIDTH, desc, Channel_A, NULL); - } - - // Channel B - if (CONTAINS(opts->type, Channel_B)) { - sprintf(desc, "%s (%s)", ch.id[img.chB], ch.name[img.chB]); - ImageOut(opts, &img, APT_CHB_OFFSET, APT_CH_WIDTH, desc, Channel_B, NULL); - } - - return 1; -} - -float *samplebuf; -static int initsnd(char *filename) { - SF_INFO infwav; - int res; - - // Open audio file - infwav.format = 0; - audioFile = sf_open(filename, SFM_READ, &infwav); - if (audioFile == NULL) { - error_noexit("Could not file"); - return 0; - } - - res = apt_init(infwav.samplerate); - printf("Input file: %s\n", filename); - if (res < 0) { - error_noexit("Input sample rate too low"); - return 0; - } else if (res > 0) { - error_noexit("Input sample rate too high"); - return 0; - } - printf("Input sample rate: %d\n", infwav.samplerate); - - channels = infwav.channels; - samplebuf = (float *)malloc(sizeof(float) * 32768 * channels); - - return 1; -} - -// Read samples from the audio file -int getsamples(void *context, float *samples, int nb) { - (void)context; - if (channels == 1) { - return (int)sf_read_float(audioFile, samples, nb); - } else if (channels == 2) { - // Stereo channels are interleaved - int samplesRead = (int)sf_read_float(audioFile, samplebuf, nb * channels); - for (int i = 0; i < nb; i++) { - samples[i] = samplebuf[i * channels]; - } - return samplesRead / channels; - } else { - printf("Only mono and stereo input files are supported\n"); - exit(1); - } -} diff --git a/src/pngio.c b/src/pngio.c deleted file mode 100644 index a061b0a..0000000 --- a/src/pngio.c +++ /dev/null @@ -1,411 +0,0 @@ -/* - * This file is part of Aptdec. - * Copyright (c) 2004-2009 Thierry Leconte (F4DWV), Xerbo (xerbo@protonmail.com) 2019-2022 - * - * Aptdec is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "pngio.h" - -#include -#include -#include -#include -#include -#include - -#include "util.h" - -int readRawImage(char *filename, float **prow, int *nrow) { - FILE *fp = fopen(filename, "rb"); - printf("%s", filename); - if (!fp) { - error_noexit("Cannot open image"); - return 0; - } - - // Create reader - png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png) { - fclose(fp); - return 0; - } - png_infop info = png_create_info_struct(png); - if (!info) { - fclose(fp); - return 0; - } - png_init_io(png, fp); - - // Read info from header - png_read_info(png, info); - int width = png_get_image_width(png, info); - int height = png_get_image_height(png, info); - png_byte color_type = png_get_color_type(png, info); - png_byte bit_depth = png_get_bit_depth(png, info); - - // Check the image - if (width != APT_IMG_WIDTH) { - error_noexit("Raw image must be 2080px wide"); - return 0; - } else if (bit_depth != 8) { - error_noexit("Raw image must have 8 bit color"); - return 0; - } else if (color_type != PNG_COLOR_TYPE_GRAY) { - error_noexit("Raw image must be grayscale"); - return 0; - } - - // Create row buffers - png_bytep *PNGrows = NULL; - PNGrows = (png_bytep *)malloc(sizeof(png_bytep) * height); - for (int y = 0; y < height; y++) PNGrows[y] = (png_byte *)malloc(png_get_rowbytes(png, info)); - - // Read image - png_read_image(png, PNGrows); - - // Tidy up - fclose(fp); - png_destroy_read_struct(&png, &info, NULL); - - // Put into prow - *nrow = height; - for (int y = 0; y < height; y++) { - prow[y] = (float *)malloc(sizeof(float) * width); - - for (int x = 0; x < width; x++) prow[y][x] = (float)PNGrows[y][x]; - } - - return 1; -} - -int readPalette(char *filename, apt_rgb_t **pixels) { - FILE *fp = fopen(filename, "rb"); - if (!fp) { - error_noexit("Cannot open palette"); - return 0; - } - - // Create reader - png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png) { - fclose(fp); - return 0; - } - png_infop info = png_create_info_struct(png); - if (!info) { - fclose(fp); - return 0; - } - png_init_io(png, fp); - - // Read info from header - png_read_info(png, info); - int width = png_get_image_width(png, info); - int height = png_get_image_height(png, info); - png_byte color_type = png_get_color_type(png, info); - png_byte bit_depth = png_get_bit_depth(png, info); - - // Check the image - if (width != 256 && height != 256) { - error_noexit("Palette must be 256x256"); - return 0; - } else if (bit_depth != 8) { - error_noexit("Palette must be 8 bit color"); - return 0; - } else if (color_type != PNG_COLOR_TYPE_RGB) { - error_noexit("Palette must be RGB"); - return 0; - } - - // Create row buffers - png_bytep *PNGrows = NULL; - PNGrows = (png_bytep *)malloc(sizeof(png_bytep) * height); - for (int y = 0; y < height; y++) PNGrows[y] = (png_byte *)malloc(png_get_rowbytes(png, info)); - - // Read image - png_read_image(png, PNGrows); - - // Tidy up - fclose(fp); - png_destroy_read_struct(&png, &info, NULL); - - // Put into crow - for (int y = 0; y < height; y++) { - pixels[y] = (apt_rgb_t *)malloc(sizeof(apt_rgb_t) * width); - - for (int x = 0; x < width; x++) - pixels[y][x] = (apt_rgb_t){PNGrows[y][x * 3], PNGrows[y][x * 3 + 1], PNGrows[y][x * 3 + 2]}; - } - - return 1; -} - -void prow2crow(float **prow, int nrow, char *palette, apt_rgb_t **crow) { - for (int y = 0; y < nrow; y++) { - crow[y] = (apt_rgb_t *)malloc(sizeof(apt_rgb_t) * APT_IMG_WIDTH); - - for (int x = 0; x < APT_IMG_WIDTH; x++) { - if (palette == NULL) - crow[y][x].r = crow[y][x].g = crow[y][x].b = prow[y][x]; - else - crow[y][x] = apt_applyPalette(palette, prow[y][x]); - } - } -} - -int applyUserPalette(float **prow, int nrow, char *filename, apt_rgb_t **crow) { - apt_rgb_t *pal_row[256]; - if (!readPalette(filename, pal_row)) { - error_noexit("Could not read palette"); - return 0; - } - - for (int y = 0; y < nrow; y++) { - for (int x = 0; x < APT_CH_WIDTH; x++) { - int cha = CLIP(prow[y][x + APT_CHA_OFFSET], 0, 255); - int chb = CLIP(prow[y][x + APT_CHB_OFFSET], 0, 255); - crow[y][x + APT_CHA_OFFSET] = pal_row[chb][cha]; - } - } - - return 1; -} - -int ImageOut(options_t *opts, apt_image_t *img, int offset, int width, char *desc, char chid, char *palette) { - char outName[512]; - if (opts->filename == NULL || opts->filename[0] == '\0') { - sprintf(outName, "%s/%s-%c.png", opts->path, img->name, chid); - } else { - sprintf(outName, "%s/%s", opts->path, opts->filename); - } - - png_text meta[] = {{PNG_TEXT_COMPRESSION_NONE, "Software", VERSION, sizeof(VERSION)}, - {PNG_TEXT_COMPRESSION_NONE, "Channel", desc, sizeof(desc)}, - {PNG_TEXT_COMPRESSION_NONE, "Description", "NOAA satellite image", 20}}; - - // Parse image type - int greyscale = 1; - switch (chid) { - case Palleted: - greyscale = 0; - break; - case Temperature: - greyscale = 0; - break; - case Raw_Image: - break; - case Channel_A: - break; - case Channel_B: - break; - } - - // Parse effects - int crop_telemetry = 0; - for (unsigned long int i = 0; i < strlen(opts->effects); i++) { - switch (opts->effects[i]) { - case Crop_Telemetry: - if (width == 2080) { - width -= APT_TOTAL_TELE; - offset += APT_SYNC_WIDTH + APT_SPC_WIDTH; - crop_telemetry = 1; - } - break; - case Precipitation_Overlay: - greyscale = 0; - break; - case Flip_Image: - break; - case Denoise: - break; - case Histogram_Equalise: - break; - case Linear_Equalise: - break; - case Crop_Noise: - break; - default: { - char text[100]; - sprintf(text, "Unrecognised effect, \"%c\"", opts->effects[i]); - warning(text); - break; - } - } - } - - FILE *pngfile; - - // Create writer - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!png_ptr) { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - error_noexit("Could not create a PNG writer"); - return 0; - } - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - error_noexit("Could not create a PNG writer"); - return 0; - } - - if (greyscale) { - // Greyscale image - png_set_IHDR(png_ptr, info_ptr, width, img->nrow, 8, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - } else { - // 8 bit RGB image - png_set_IHDR(png_ptr, info_ptr, width, img->nrow, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - } - - png_set_text(png_ptr, info_ptr, meta, 3); - png_set_pHYs(png_ptr, info_ptr, 3636, 3636, PNG_RESOLUTION_METER); - - // Init I/O - pngfile = fopen(outName, "wb"); - if (!pngfile) { - error_noexit("Could not open PNG for writing"); - return 1; - } - png_init_io(png_ptr, pngfile); - png_write_info(png_ptr, info_ptr); - - // Move prow into crow, crow ~ color rows, if required - apt_rgb_t *crow[APT_MAX_HEIGHT]; - if (!greyscale) { - prow2crow(img->prow, img->nrow, palette, crow); - } - - // Apply a user provided color palette - if (chid == Palleted) { - applyUserPalette(img->prow, img->nrow, opts->palette, crow); - } - - // Precipitation overlay - if (CONTAINS(opts->effects, Precipitation_Overlay)) { - for (int y = 0; y < img->nrow; y++) { - for (int x = 0; x < APT_CH_WIDTH; x++) { - if (img->prow[y][x + APT_CHB_OFFSET] >= 198) - crow[y][x + APT_CHB_OFFSET] = crow[y][x + APT_CHA_OFFSET] = - apt_applyPalette(apt_PrecipPalette, img->prow[y][x + APT_CHB_OFFSET] - 198); - } - } - } - - printf("Writing %s", outName); - -// Float power macro (for gamma adjustment) -#define POWF(a, b) (b == 1.0 ? a : exp(b * log(a))) - float a = POWF(255, opts->gamma) / 255; - - // Build image - for (int y = 0; y < img->nrow; y++) { - png_color pix[APT_IMG_WIDTH]; // Color - png_byte mpix[APT_IMG_WIDTH]; // Mono - - int skip = 0; - for (int x = 0; x < width; x++) { - if (crop_telemetry && x == APT_CH_WIDTH) skip += APT_TELE_WIDTH + APT_SYNC_WIDTH + APT_SPC_WIDTH; - - if (greyscale) { - mpix[x] = POWF(img->prow[y][x + skip + offset], opts->gamma) / a; - } else { - pix[x] = (png_color){POWF(crow[y][x + skip + offset].r, opts->gamma) / a, - POWF(crow[y][x + skip + offset].g, opts->gamma) / a, - POWF(crow[y][x + skip + offset].b, opts->gamma) / a}; - } - } - - if (greyscale) { - png_write_row(png_ptr, (png_bytep)mpix); - } else { - png_write_row(png_ptr, (png_bytep)pix); - } - } - - // Tidy up - png_write_end(png_ptr, info_ptr); - fclose(pngfile); - printf("\nDone\n"); - png_destroy_write_struct(&png_ptr, &info_ptr); - - return 1; -} - -// TODO: clean up everthing below this comment -png_structp rt_png_ptr; -png_infop rt_info_ptr; -FILE *rt_pngfile; - -int initWriter(options_t *opts, apt_image_t *img, int width, int height, char *desc, char *chid) { - char outName[384]; - sprintf(outName, "%s/%s-%s.png", opts->path, img->name, chid); - - png_text meta[] = {{PNG_TEXT_COMPRESSION_NONE, "Software", VERSION, sizeof(VERSION)}, - {PNG_TEXT_COMPRESSION_NONE, "Channel", desc, sizeof(desc)}, - {PNG_TEXT_COMPRESSION_NONE, "Description", "NOAA satellite image", 20}}; - - // Create writer - rt_png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!rt_png_ptr) { - png_destroy_write_struct(&rt_png_ptr, (png_infopp)NULL); - error_noexit("Could not create a PNG writer"); - return 0; - } - rt_info_ptr = png_create_info_struct(rt_png_ptr); - if (!rt_info_ptr) { - png_destroy_write_struct(&rt_png_ptr, (png_infopp)NULL); - error_noexit("Could not create a PNG writer"); - return 0; - } - - // Greyscale image - png_set_IHDR(rt_png_ptr, rt_info_ptr, width, height, 8, PNG_COLOR_TYPE_GRAY, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - - png_set_text(rt_png_ptr, rt_info_ptr, meta, 3); - - // Channel = 25cm wide - png_set_pHYs(rt_png_ptr, rt_info_ptr, 3636, 3636, PNG_RESOLUTION_METER); - - // Init I/O - rt_pngfile = fopen(outName, "wb"); - if (!rt_pngfile) { - error_noexit("Could not open PNG for writing"); - return 0; - } - png_init_io(rt_png_ptr, rt_pngfile); - png_write_info(rt_png_ptr, rt_info_ptr); - - // Turn off compression - png_set_compression_level(rt_png_ptr, 0); - - return 1; -} - -void pushRow(float *row, int width) { - png_byte pix[APT_IMG_WIDTH]; - for (int i = 0; i < width; i++) pix[i] = row[i]; - - png_write_row(rt_png_ptr, (png_bytep)pix); -} - -void closeWriter() { - png_write_end(rt_png_ptr, rt_info_ptr); - fclose(rt_pngfile); - png_destroy_write_struct(&rt_png_ptr, &rt_info_ptr); -} diff --git a/src/pngio.h b/src/pngio.h deleted file mode 100644 index f812b3e..0000000 --- a/src/pngio.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "apt.h" -#include "common.h" - -int readRawImage(char *filename, float **prow, int *nrow); -int readPalette(char *filename, apt_rgb_t **pixels); -void prow2crow(float **prow, int nrow, char *palette, apt_rgb_t **crow); -int applyUserPalette(float **prow, int nrow, char *filename, apt_rgb_t **crow); -int ImageOut(options_t *opts, apt_image_t *img, int offset, int width, char *desc, char chid, char *palette); -int initWriter(options_t *opts, apt_image_t *img, int width, int height, char *desc, char *chid); -void pushRow(float *row, int width); -void closeWriter(); diff --git a/src/taps.h b/src/taps.h deleted file mode 100644 index f33b892..0000000 --- a/src/taps.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * aptdec - A lightweight FOSS (NOAA) APT decoder - * Copyright (C) 2004-2009 Thierry Leconte (F4DWV) 2019-2022 Xerbo (xerbo@protonmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -static const float hilbert_filter[] = {0.0205361, 0.0219524, 0.0235785, 0.0254648, 0.0276791, 0.0303152, 0.0335063, - 0.0374482, 0.0424413, 0.0489708, 0.0578745, 0.0707355, 0.0909457, 0.127324, - 0.212207, 0.63662, -0.63662, -0.212207, -0.127324, -0.0909457, -0.0707355, - -0.0578745, -0.0489708, -0.0424413, -0.0374482, -0.0335063, -0.0303152, -0.0276791, - -0.0254648, -0.0235785, -0.0219524, -0.0205361}; -#define HILBERT_FILTER_SIZE (sizeof(hilbert_filter) / sizeof(hilbert_filter[0])) - -static const float low_pass[] = { - -3.37279e-04, -8.80292e-06, -3.96418e-04, -1.78544e-04, -5.27511e-04, -3.75376e-04, -6.95337e-04, -5.93148e-04, -8.79730e-04, - -8.15327e-04, -1.05669e-03, -1.01377e-03, -1.19836e-03, -1.15443e-03, -1.26937e-03, -1.20955e-03, -1.23904e-03, -1.15302e-03, - -1.08660e-03, -9.64235e-04, -8.02450e-04, -6.46202e-04, -3.95376e-04, -2.18096e-04, 1.11906e-04, 2.89567e-04, 6.67167e-04, - 8.19039e-04, 1.21725e-03, 1.30556e-03, 1.69365e-03, 1.68588e-03, 2.03277e-03, 1.90159e-03, 2.18455e-03, 1.90833e-03, - 2.12100e-03, 1.69052e-03, 1.77484e-03, 1.42542e-03, 1.18292e-03, 8.66979e-04, 5.54161e-04, 2.15793e-04, -1.11623e-04, - -4.35173e-04, -7.27194e-04, -9.91551e-04, -1.20407e-03, -1.37032e-03, -1.46991e-03, -1.51120e-03, -1.48008e-03, -1.39047e-03, - -1.23115e-03, -1.02128e-03, -7.60099e-04, -4.68008e-04, -1.46339e-04, 1.80867e-04, 5.11244e-04, 8.19243e-04, 1.09739e-03, - 1.32668e-03, 1.50632e-03, 1.61522e-03, 1.66246e-03, 1.62390e-03, 1.52430e-03, 1.34273e-03, 1.10736e-03, 8.10335e-04, - 4.76814e-04, 1.13622e-04, -2.64150e-04, -6.26595e-04, -9.95436e-04, -1.27846e-03, -1.54080e-03, -1.74292e-03, -1.86141e-03, - -1.89318e-03, -1.83969e-03, -1.69770e-03, -1.47938e-03, -1.18696e-03, -8.37003e-04, -4.39507e-04, -1.56907e-05, 4.19904e-04, - 8.43172e-04, 1.23827e-03, 1.58411e-03, 1.86382e-03, 2.06312e-03, 2.17177e-03, 2.18121e-03, 2.08906e-03, 1.89772e-03, - 1.61153e-03, 1.24507e-03, 8.13976e-04, 3.29944e-04, -1.74591e-04, -6.83619e-04, -1.17826e-03, -1.61659e-03, -2.00403e-03, - -2.29070e-03, -2.49179e-03, -2.56546e-03, -2.53448e-03, -2.37032e-03, -2.10060e-03, -1.72140e-03, -1.24542e-03, -7.15425e-04, - -1.24964e-04, 4.83736e-04, 1.08328e-03, 1.64530e-03, 2.14503e-03, 2.55400e-03, 2.85589e-03, 3.02785e-03, 3.06271e-03, - 2.95067e-03, 2.69770e-03, 2.30599e-03, 1.79763e-03, 1.18587e-03, 5.04003e-04, -2.23591e-04, -9.57591e-04, -1.66939e-03, - -2.31717e-03, -2.87636e-03, -3.31209e-03, -3.60506e-03, -3.73609e-03, -3.69208e-03, -3.44913e-03, -3.06572e-03, -2.50229e-03, - -1.80630e-03, -1.00532e-03, -1.22305e-04, 7.83910e-04, 1.69402e-03, 2.53826e-03, 3.30312e-03, 3.91841e-03, 4.38017e-03, - 4.63546e-03, 4.68091e-03, 4.50037e-03, 4.09614e-03, 3.47811e-03, 2.67306e-03, 1.70418e-03, 6.20542e-04, -5.36994e-04, - -1.70981e-03, -2.84712e-03, -3.88827e-03, -4.78659e-03, -5.48593e-03, -5.95049e-03, -6.14483e-03, -6.05118e-03, -5.65829e-03, - -4.97525e-03, -4.01796e-03, -2.82224e-03, -1.43003e-03, 1.00410e-04, 1.71169e-03, 3.31983e-03, 4.87796e-03, 6.23237e-03, - 7.31013e-03, 8.20642e-03, 8.67374e-03, 8.77681e-03, 8.43444e-03, 7.66794e-03, 6.46827e-03, 4.87294e-03, 2.92923e-03, - 6.98913e-04, -1.72126e-03, -4.24785e-03, -6.75380e-03, -9.13309e-03, -1.12532e-02, -1.30038e-02, -1.42633e-02, -1.49338e-02, - -1.49145e-02, -1.41484e-02, -1.25761e-02, -1.01870e-02, -6.97432e-03, -2.97910e-03, 1.75386e-03, 7.11899e-03, 1.30225e-02, - 1.93173e-02, 2.58685e-02, 3.24965e-02, 3.90469e-02, 4.53316e-02, 5.11931e-02, 5.64604e-02, 6.09924e-02, 6.46584e-02, - 6.73547e-02, 6.90049e-02, 6.97096e-02, 6.90049e-02, 6.73547e-02, 6.46584e-02, 6.09924e-02, 5.64604e-02, 5.11931e-02, - 4.53316e-02, 3.90469e-02, 3.24965e-02, 2.58685e-02, 1.93173e-02, 1.30225e-02, 7.11899e-03, 1.75386e-03, -2.97910e-03, - -6.97432e-03, -1.01870e-02, -1.25761e-02, -1.41484e-02, -1.49145e-02, -1.49338e-02, -1.42633e-02, -1.30038e-02, -1.12532e-02, - -9.13309e-03, -6.75380e-03, -4.24785e-03, -1.72126e-03, 6.98913e-04, 2.92923e-03, 4.87294e-03, 6.46827e-03, 7.66794e-03, - 8.43444e-03, 8.77681e-03, 8.67374e-03, 8.20642e-03, 7.31013e-03, 6.23237e-03, 4.87796e-03, 3.31983e-03, 1.71169e-03, - 1.00410e-04, -1.43003e-03, -2.82224e-03, -4.01796e-03, -4.97525e-03, -5.65829e-03, -6.05118e-03, -6.14483e-03, -5.95049e-03, - -5.48593e-03, -4.78659e-03, -3.88827e-03, -2.84712e-03, -1.70981e-03, -5.36994e-04, 6.20542e-04, 1.70418e-03, 2.67306e-03, - 3.47811e-03, 4.09614e-03, 4.50037e-03, 4.68091e-03, 4.63546e-03, 4.38017e-03, 3.91841e-03, 3.30312e-03, 2.53826e-03, - 1.69402e-03, 7.83910e-04, -1.22305e-04, -1.00532e-03, -1.80630e-03, -2.50229e-03, -3.06572e-03, -3.44913e-03, -3.69208e-03, - -3.73609e-03, -3.60506e-03, -3.31209e-03, -2.87636e-03, -2.31717e-03, -1.66939e-03, -9.57591e-04, -2.23591e-04, 5.04003e-04, - 1.18587e-03, 1.79763e-03, 2.30599e-03, 2.69770e-03, 2.95067e-03, 3.06271e-03, 3.02785e-03, 2.85589e-03, 2.55400e-03, - 2.14503e-03, 1.64530e-03, 1.08328e-03, 4.83736e-04, -1.24964e-04, -7.15425e-04, -1.24542e-03, -1.72140e-03, -2.10060e-03, - -2.37032e-03, -2.53448e-03, -2.56546e-03, -2.49179e-03, -2.29070e-03, -2.00403e-03, -1.61659e-03, -1.17826e-03, -6.83619e-04, - -1.74591e-04, 3.29944e-04, 8.13976e-04, 1.24507e-03, 1.61153e-03, 1.89772e-03, 2.08906e-03, 2.18121e-03, 2.17177e-03, - 2.06312e-03, 1.86382e-03, 1.58411e-03, 1.23827e-03, 8.43172e-04, 4.19904e-04, -1.56907e-05, -4.39507e-04, -8.37003e-04, - -1.18696e-03, -1.47938e-03, -1.69770e-03, -1.83969e-03, -1.89318e-03, -1.86141e-03, -1.74292e-03, -1.54080e-03, -1.27846e-03, - -9.95436e-04, -6.26595e-04, -2.64150e-04, 1.13622e-04, 4.76814e-04, 8.10335e-04, 1.10736e-03, 1.34273e-03, 1.52430e-03, - 1.62390e-03, 1.66246e-03, 1.61522e-03, 1.50632e-03, 1.32668e-03, 1.09739e-03, 8.19243e-04, 5.11244e-04, 1.80867e-04, - -1.46339e-04, -4.68008e-04, -7.60099e-04, -1.02128e-03, -1.23115e-03, -1.39047e-03, -1.48008e-03, -1.51120e-03, -1.46991e-03, - -1.37032e-03, -1.20407e-03, -9.91551e-04, -7.27194e-04, -4.35173e-04, -1.11623e-04, 2.15793e-04, 5.54161e-04, 8.66979e-04, - 1.18292e-03, 1.42542e-03, 1.77484e-03, 1.69052e-03, 2.12100e-03, 1.90833e-03, 2.18455e-03, 1.90159e-03, 2.03277e-03, - 1.68588e-03, 1.69365e-03, 1.30556e-03, 1.21725e-03, 8.19039e-04, 6.67167e-04, 2.89567e-04, 1.11906e-04, -2.18096e-04, - -3.95376e-04, -6.46202e-04, -8.02450e-04, -9.64235e-04, -1.08660e-03, -1.15302e-03, -1.23904e-03, -1.20955e-03, -1.26937e-03, - -1.15443e-03, -1.19836e-03, -1.01377e-03, -1.05669e-03, -8.15327e-04, -8.79730e-04, -5.93148e-04, -6.95337e-04, -3.75376e-04, - -5.27511e-04, -1.78544e-04, -3.96418e-04, -8.80292e-06, -3.37279e-04}; -#define LOW_PASS_SIZE (sizeof(low_pass) / sizeof(low_pass[0])) - -static const float sync_pattern[] = {-14, -14, -14, 18, 18, -14, -14, 18, 18, -14, -14, 18, 18, -14, -14, 18, - 18, -14, -14, 18, 18, -14, -14, 18, 18, -14, -14, 18, 18, -14, -14, -14}; -#define SYNC_PATTERN_SIZE (sizeof(sync_pattern) / sizeof(sync_pattern[0])) diff --git a/util/PrecipitationPalette.png b/util/PrecipitationPalette.png index 2ac2db0d4ad1cea1b77eac2bfc3669f66019087c..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|{YiSQrA3c`-fiIGx~0i`z~v4w@T5zIUA*>z#n&VLU*@>4HJ7xwHQxse?? z0X>Yu`Men3qqbMS^?R7!f^MT~)XW~Hx8Zw*K8<{@pk~wSEsh{SYSfJ8jEfTG~Sa7#Z-hA@q886 zo0uZ!dd}@bv){e@9gz#_16_Day@^=UA2@kd5%Z{#JusF#GmB{veHTxE#HU4EbpI!( hKBJ!cRidSr^cO^3fy<w|yT`Y)-2rgQMB2);qLaPoYmwrK$h9t$sQE)9d__0`ZaBh822neDNBbbqy zWz0!Z0>0zx9s$1IMR}J0xj#p@nza}Z5Q%4*VcNtS#8aEL!FiuJ%nGtfd`>)S(gleh zxvqHp#yRh@z%#>UDmhOaCKmH8th6vIm>TgUaYWU0$`{fetDLtuYo!Wn+>^gBl+{<3 zxlVHsaV%m95`RP}sGx`vY(#0*NwJWm{g{t`!1YVyQpi;VBgX>D&>*{h@IUz7t(BV? z_mV;}p#8;hK8ApfU7%idobO}Dsh2ve$jy-PzjPzh@f# z{Q#lxa=KPDOWXhe00v@9M??TZ02~1NlO*v#ks%m=lu1NER5*=ok;`t>KoCVwpDJ4( z!f)|?d{q=B5}H+5^VowB8!~=03s3jNfz8pad#kETHXry{Er^9eQ#S(7u({*;m*ITZu+7=XR29kk-^!Ea}9n%b%?t#6-*R;J)kzz8t9m)X30GtuwcXY-KmK}Qr&!2}FIOINg; zT^ptXGJ}t2@cax;*(YkB*jnj!@S+}&TMuriV644d!Cbm`!_jjA^U?x)i}OKw0jC)( vtQ+|72mCaHCk`JXdie&!v2Oqzy9e+WNqU0HCBBG400000NkvXXu0mjfH(ifA diff --git a/util/Temperature.png b/util/Temperature.png index 012f57ff721b44f058a8c096359dad3cd7ed8436..fa5bb0e0ebd18eb3454ea8f4a268706ea658158c 100644 GIT binary patch delta 11 Scmcb|zlUdn^5&zAl57ARw*&zI delta 430 zcmV;f0a5EX>4Tx04R}tkv&MmKpe$iQ%j{(9PA+C zkfAzR5fydRDionYsTEpvFuC*#nlvOSE{=k0!NHHks)LKOt`4q(Aou~|}?mh0_0Yam~RI_UgP&La)C*oo@w<-o-As~PdMt?CaF;kyQrIPR*U-$6w z^)AM|nWrS;by?xO#aXS?SnHnrh2gxmvdndwgGgWzOGrV4 zj2gUH6XR}DI1U6}Z2Myf z2<`&Sx@~_S+jjE=@IM1rTH9Z305hMY*V|h32@ctJ^&f&DtQAO90J2d%3k+)cO!RaZ~vZY_4fmiZ*sF8DkEtC Y000JJOGiWi{{a60|De66ld&Ni20>cJ@&Et; diff --git a/util/img2gradient.py b/util/img2gradient.py new file mode 100755 index 0000000..815cda7 --- /dev/null +++ b/util/img2gradient.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +import sys +from PIL import Image + +""" +Converts a PNG into a gradient compatible +with aptdec. Requires Pillow: + + pip3 install Pillow + +""" + +if len(sys.argv) == 1: + print("Usage: {} filename.png".format(sys.argv[0])) + exit() + +image = Image.open(sys.argv[1]) +pixels = image.load() + +if len(pixels[0, 0]) != 3: + print("Image must be RGB") + exit() + +if image.size[0] != 1: + print("Image must be 1px wide") + exit() + +print("uint32_t gradient[{}] = {{\n ".format(image.size[1]), end="") +for y in range(image.size[1]): + print("0x" + "".join("{:02X}".format(a) for a in pixels[0, y]), end="") + + if y != image.size[1] - 1: + print(", ", end="") + if y % 7 == 6: + print("\n ", end="") + +print("\n};") diff --git a/util/img2pal.py b/util/img2pal.py deleted file mode 100644 index f5c3753..0000000 --- a/util/img2pal.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python3 -import sys -from PIL import Image - -''' -Converts a PNG into a palette compatible -with aptdec. Requires PIL: - - pip3 install Pillow - -''' - -if len(sys.argv) == 1: - print("Usage: python3 {} filename.png".format(sys.argv[0])) - exit() - -image = Image.open(sys.argv[1]) -pixels = image.load() - -sys.stdout.write("char palette[{}*3] = {{\n \"".format(image.size[1])) -for y in range(1, image.size[1]+1): - sys.stdout.write(''.join('\\x{:02x}'.format(a) for a in pixels[0, y-1])) - if(y % 7 == 0 and y != 0): - sys.stdout.write("\"\n \"") - -print("\"\n};") From 268da89200cbed4aed12b048f7686b9bf59db165 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Mon, 16 Jan 2023 22:33:56 +0000 Subject: [PATCH 02/19] Fix argparse submodule --- aptdec-cli/argparse | 1 + 1 file changed, 1 insertion(+) create mode 160000 aptdec-cli/argparse diff --git a/aptdec-cli/argparse b/aptdec-cli/argparse new file mode 160000 index 0000000..1509171 --- /dev/null +++ b/aptdec-cli/argparse @@ -0,0 +1 @@ +Subproject commit 15091715cc379bc647d5de6345185a288a35f999 From ff19b2823c3f57ba80334eafbc1b0c05519c9de5 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sat, 21 Jan 2023 22:35:27 +0000 Subject: [PATCH 03/19] Packaging fixes --- .github/ISSUE_TEMPLATE/bug-report.md | 3 +- .github/workflows/build.yml | 54 +++++--------- .github/workflows/release.yml | 108 ++++++++++++--------------- CMakeLists.txt | 32 ++++---- build_windows.sh | 70 +++++++---------- cmake/toolchain-mingw32.cmake | 1 + 6 files changed, 111 insertions(+), 157 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index d51896d..41036f7 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -11,7 +11,7 @@ assignees: '' A clear description of what the bug is. **To Reproduce** -Steps to reproduce the behaviour. +Steps to reproduce the behavior. **Expected behaviour** A clear description of what you expected to happen. @@ -21,4 +21,3 @@ A link to the audio that caused the problem. **Build information** The commit of aptdec you are running (check with `git rev-parse HEAD`), make sure it's up to date before opening this issue. -And whether you are using GNU automake or CMake. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf809e6..8960cb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,9 +10,6 @@ on: paths-ignore: - '**.md' -env: - BUILD_TYPE: Release - jobs: build_linux: runs-on: ubuntu-latest @@ -23,35 +20,25 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root run: sudo apt-get install cmake git gcc libsndfile-dev libpng-dev - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{runner.workspace}}/build + - name: Configure cmake + run: cmake -B build -DCMAKE_BUILD_TYPE=Release - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + - name: Build and package + run: cmake --build build -j$(nproc) && cmake --build build --target package - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE + - name: Upload TGZ package + uses: actions/upload-artifact@v3 + with: + name: TGZ package + path: build/aptdec/aptdec_*.tar.gz - - name: Upload compilied binary - uses: actions/upload-artifact@v2 + - name: Upload DEB package + uses: actions/upload-artifact@v3 with: - name: aptdec_lin64 - path: ${{runner.workspace}}/build/aptdec + name: Debian package + path: build/aptdec/aptdec_*.deb build_windows: runs-on: ubuntu-latest @@ -62,16 +49,13 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root - run: sudo apt install wget cmake make mingw-w64 git unzip libsndfile-dev + run: sudo apt install cmake git mingw-w64 unzip - name: Run build script - shell: bash - working-directory: ${{runner.workspace}} - run: cd $GITHUB_WORKSPACE && ./build_windows.sh $BUILD_TYPE + run: ./build_windows.sh $BUILD_TYPE - - name: Upload compilied binary - uses: actions/upload-artifact@v2 + - name: Upload ZIP package + uses: actions/upload-artifact@v3 with: - name: aptdec-win64.zip - path: ${{runner.workspace}}/aptdec/winbuild/aptdec-1.7.0.zip + name: ZIP package + path: build/aptdec/aptdec_*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b49e8d2..1f7dce4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,44 @@ -name: Build +name: Build (release) on: push: tags: - 'v*' -env: - BUILD_TYPE: Release - jobs: - prepare_release: + create_release: runs-on: ubuntu-latest - outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} + needs: [ build_linux, build_windows ] steps: + - name: Download TGZ package + uses: actions/download-artifact@v3 + with: + name: TGZ package + + - name: Download DEB package + uses: actions/download-artifact@v3 + with: + name: DEB package + + - name: Download ZIP package + uses: actions/download-artifact@v3 + with: + name: ZIP package + + - name: Test + run: ls -la + - name: Create Release - uses: actions/create-release@v1 - id: create_release + uses: softprops/action-gh-release@v1 with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - body: A release wow - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + files: | + aptdec_$GITHUB_REF_NAME.x86_64.tar.gz + aptdec_$GITHUB_REF_NAME.x86_64.deb + aptdec_$GITHUB_REF_NAME.amd64.zip build_linux: runs-on: ubuntu-latest - needs: [prepare_release] steps: - uses: actions/checkout@v3 @@ -37,44 +46,28 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root run: sudo apt-get install cmake git gcc libsndfile-dev libpng-dev - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Upload binary - uses: actions/upload-release-asset@v1 + - name: Configure cmake + run: cmake -B build -DCMAKE_BUILD_TYPE=Release + + - name: Build and package + run: cmake --build build -j$(nproc) && cmake --build build --target package + + - name: Upload TGZ package + uses: actions/upload-artifact@v3 with: - upload_url: ${{ needs.prepare_release.outputs.upload_url }} - asset_path: ./${{runner.workspace}}/aptdec/build/aptdec - asset_name: aptdec_lin64 - asset_content_type: application/x-executable - env: - GITHUB_TOKEN: ${{ github.token }} + name: TGZ package + path: build/aptdec/aptdec_*.tar.gz + - name: Upload DEB package + uses: actions/upload-artifact@v3 + with: + name: Debian package + path: build/aptdec/aptdec_*.deb build_windows: runs-on: ubuntu-latest - needs: [prepare_release] steps: - uses: actions/checkout@v3 @@ -82,20 +75,13 @@ jobs: submodules: 'recursive' - name: Install dependencies - # The user does not run as root - run: sudo apt install wget cmake make mingw-w64 git unzip libsndfile-dev + run: sudo apt install cmake git mingw-w64 unzip - name: Run build script - shell: bash - working-directory: ${{runner.workspace}} - run: cd $GITHUB_WORKSPACE && ./build_windows.sh $BUILD_TYPE + run: ./build_windows.sh $BUILD_TYPE - - name: Upload zip - uses: actions/upload-release-asset@v1 + - name: Upload ZIP package + uses: actions/upload-artifact@v3 with: - upload_url: ${{ needs.prepare_release.outputs.upload_url }} - asset_path: ./${{runner.workspace}}/aptdec/winbuild/aptdec-1.7.0.zip - asset_name: aptdec_win64.zip - asset_content_type: application/zip - env: - GITHUB_TOKEN: ${{ github.token }} + name: ZIP package + path: build/aptdec/aptdec_*.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index 843a97d..e5f3a09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include(GNUInstallDirs) # aptdec-cli find_package(PNG) find_path(SNDFILE_INCLUDE_DIR sndfile.h) -find_library(SNDFILE_LIBRARIES NAMES sndfile libsndfile PATH) +find_library(SNDFILE_LIBRARIES NAMES sndfile libsndfile) if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR) set(APTDEC_CLI_SOURCE_FILES @@ -43,6 +43,10 @@ if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR) target_link_libraries(aptdec-cli PRIVATE m) target_compile_options(aptdec-cli PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() + + install(TARGETS aptdec-cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + file(GLOB LUTS luts/*.png) + install(FILES ${LUTS} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/aptdec/luts) else() message(WARNING "Not building aptdec-cli as some/all required dependencies are missing, libaptdec will still be built") endif() @@ -72,32 +76,24 @@ else() target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() +install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + # Packaging set(CPACK_PACKAGE_VERSION "${VERSION}") set(CPACK_PACKAGE_NAME "aptdec") set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder") set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS library/program that decodes images transmitted by the NOAA POES weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.") +set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}") set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) -if(NOT WIN32) - set(CPACK_GENERATOR "DEB;TGZ") - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}") -else() - #set(CPACK_GENERATOR "ZIP;NSIS") - set(CPACK_GENERATOR "ZIP") - set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") - - if (TARGET aptdec) - file(GLOB_RECURSE DLLS *.dll) - install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR}) - endif() -endif() +if(WIN32) + file(GLOB DLLS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/*.dll) + install(FILES ${DLLS} DESTINATION ${CMAKE_INSTALL_BINDIR}) -if(TARGET aptdec-cli) - install(TARGETS aptdec RUNTIME DESTINATION bin) + set(CPACK_GENERATOR "ZIP") +else() + set(CPACK_GENERATOR "DEB;TGZ") endif() -install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) - include(CPack) diff --git a/build_windows.sh b/build_windows.sh index 5d9558f..987c11e 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -1,54 +1,42 @@ #!/usr/bin/env bash # Cross compile for Windows from Linux - -TEMP_PATH="$(pwd)/winpath" set -e -# Compile and build zlib -if [ -d "zlib" ]; then - cd zlib && git pull -else - git clone https://github.com/madler/zlib && cd zlib +TEMP_PATH="$(pwd)/winpath" +BUILD_DIR="winbuild" + +# Build zlib from source +if [ ! -d "zlib" ]; then + git clone -b v1.2.13 https://github.com/madler/zlib && cd zlib + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH + cmake --build build -j$(nproc) + cmake --build build --target install + cd .. fi -mkdir -p build && cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. -make -j4 -make install -cd ../.. - -# Clone and build ligpng -if [ -d "libpng" ]; then - cd libpng && git pull -else - git clone https://github.com/glennrp/libpng && cd libpng +# Build libpng from source +if [ ! -d "libpng" ]; then + git clone -b v1.6.39 https://github.com/glennrp/libpng && cd libpng + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH + cmake --build build -j$(nproc) + cmake --build build --target install + cd .. fi -mkdir -p build && cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. -make -j4 -make install -cd ../.. - # Download libsndfile -if [ ! -d "libsndfile-1.0.29-win64" ]; then - wget https://github.com/erikd/libsndfile/releases/download/v1.0.29/libsndfile-1.0.29-win64.zip - unzip libsndfile-1.0.29-win64.zip +if [ ! -d libsndfile-1.2.0-win64 ]; then + wget https://github.com/libsndfile/libsndfile/releases/download/1.2.0/libsndfile-1.2.0-win64.zip + unzip libsndfile-1.2.0-win64.zip + cp "libsndfile-1.2.0-win64/bin/sndfile.dll" $TEMP_PATH/bin + cp "libsndfile-1.2.0-win64/include/sndfile.h" $TEMP_PATH/include + cp "libsndfile-1.2.0-win64/lib/sndfile.lib" $TEMP_PATH/lib fi -cp "libsndfile-1.0.29-win64/bin/sndfile.dll" $TEMP_PATH/bin/sndfile.dll -cp "libsndfile-1.0.29-win64/include/sndfile.h" $TEMP_PATH/include/sndfile.h -cp "libsndfile-1.0.29-win64/lib/sndfile.lib" $TEMP_PATH/lib/sndfile.lib - -# Copy DLL's into root for CPack -cp $TEMP_PATH/bin/*.dll ../ -buildtype="Debug" -if [[ "$1" == "Release" ]]; then - buildtype="Release" -fi +# Copy required GCC libs +cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll $TEMP_PATH/bin +cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll $TEMP_PATH/bin # Build aptdec -mkdir -p winbuild && cd winbuild -cmake -DCMAKE_BUILD_TYPE=$buildtype -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. -make -j 4 -make package +cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH +cmake --build $BUILD_DIR -j$(nproc) +cmake --build $BUILD_DIR --target package diff --git a/cmake/toolchain-mingw32.cmake b/cmake/toolchain-mingw32.cmake index b316fd3..de03f7e 100644 --- a/cmake/toolchain-mingw32.cmake +++ b/cmake/toolchain-mingw32.cmake @@ -1,5 +1,6 @@ # the name of the target operating system SET(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_SYSTEM_PROCESSOR amd64) # which compilers to use for C and C++ SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) From 0d212bb684d4d6791d84b863397810962892857c Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sat, 21 Jan 2023 22:40:38 +0000 Subject: [PATCH 04/19] Add windows build files to gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 69c083f..d4e410a 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,9 @@ _deps *.ogg build/ +winbuild/ +winpath/ +zlib/ +libpng/ +libsndfile-*-win64.zip +libsndfile-*-win64/ From 0d5195434e3ee95d516a003edf6b3f32fc09ef86 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sat, 21 Jan 2023 22:50:13 +0000 Subject: [PATCH 05/19] Github actions, set fetch depth to unlimited --- .github/workflows/build.yml | 2 ++ .github/workflows/release.yml | 4 +++- build_windows.sh | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8960cb7..d49bb48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: 'recursive' + fetch-depth: 0 - name: Install dependencies run: sudo apt-get install cmake git gcc libsndfile-dev libpng-dev @@ -47,6 +48,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: 'recursive' + fetch-depth: 0 - name: Install dependencies run: sudo apt install cmake git mingw-w64 unzip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f7dce4..e249d56 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,8 @@ jobs: - uses: actions/checkout@v3 with: submodules: 'recursive' - + fetch-depth: 0 + - name: Install dependencies run: sudo apt-get install cmake git gcc libsndfile-dev libpng-dev @@ -73,6 +74,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: 'recursive' + fetch-depth: 0 - name: Install dependencies run: sudo apt install cmake git mingw-w64 unzip diff --git a/build_windows.sh b/build_windows.sh index 987c11e..5fa5c4a 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -33,8 +33,8 @@ if [ ! -d libsndfile-1.2.0-win64 ]; then fi # Copy required GCC libs -cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libgcc_s_seh-1.dll $TEMP_PATH/bin -cp /usr/x86_64-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll $TEMP_PATH/bin +cp $(find /usr | grep libgcc_s_seh-1.dll) $TEMP_PATH/bin +cp $(find /usr | grep libwinpthread-1.dll) $TEMP_PATH/bin # Build aptdec cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH From 493a48b2639be73aec7b0fd8087f9afa10ab1d55 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sat, 21 Jan 2023 22:54:28 +0000 Subject: [PATCH 06/19] Fix incorrect path --- .github/workflows/build.yml | 6 +++--- .github/workflows/release.yml | 6 +++--- build_windows.sh | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d49bb48..96197d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,13 +33,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: TGZ package - path: build/aptdec/aptdec_*.tar.gz + path: build/aptdec_*.tar.gz - name: Upload DEB package uses: actions/upload-artifact@v3 with: name: Debian package - path: build/aptdec/aptdec_*.deb + path: build/aptdec_*.deb build_windows: runs-on: ubuntu-latest @@ -60,4 +60,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ZIP package - path: build/aptdec/aptdec_*.zip + path: build/aptdec_*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e249d56..6eb4f4e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,13 +59,13 @@ jobs: uses: actions/upload-artifact@v3 with: name: TGZ package - path: build/aptdec/aptdec_*.tar.gz + path: build/aptdec_*.tar.gz - name: Upload DEB package uses: actions/upload-artifact@v3 with: name: Debian package - path: build/aptdec/aptdec_*.deb + path: build/aptdec_*.deb build_windows: runs-on: ubuntu-latest @@ -86,4 +86,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ZIP package - path: build/aptdec/aptdec_*.zip + path: build/aptdec_*.zip diff --git a/build_windows.sh b/build_windows.sh index 5fa5c4a..3f178a5 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -33,8 +33,8 @@ if [ ! -d libsndfile-1.2.0-win64 ]; then fi # Copy required GCC libs -cp $(find /usr | grep libgcc_s_seh-1.dll) $TEMP_PATH/bin -cp $(find /usr | grep libwinpthread-1.dll) $TEMP_PATH/bin +cp $(find /usr | grep libgcc_s_seh-1.dll | head -n 1) $TEMP_PATH/bin +cp $(find /usr | grep libwinpthread-1.dll | head -n 1) $TEMP_PATH/bin # Build aptdec cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH From f394f6a356eef36fc8c6ad8a6c7be27c119a60a6 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sun, 22 Jan 2023 13:46:15 +0000 Subject: [PATCH 07/19] Make build_windows.sh faster --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 2 +- build_windows.sh | 23 +++++++++++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96197d9..c4acba6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,4 +60,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ZIP package - path: build/aptdec_*.zip + path: winbuild/aptdec_*.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6eb4f4e..3176de3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -86,4 +86,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: ZIP package - path: build/aptdec_*.zip + path: winbuild/aptdec_*.zip diff --git a/build_windows.sh b/build_windows.sh index 3f178a5..40bf725 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -7,7 +7,7 @@ BUILD_DIR="winbuild" # Build zlib from source if [ ! -d "zlib" ]; then - git clone -b v1.2.13 https://github.com/madler/zlib && cd zlib + git clone --depth 1 -b v1.2.13 https://github.com/madler/zlib && cd zlib cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH cmake --build build -j$(nproc) cmake --build build --target install @@ -16,7 +16,7 @@ fi # Build libpng from source if [ ! -d "libpng" ]; then - git clone -b v1.6.39 https://github.com/glennrp/libpng && cd libpng + git clone --depth 1 -b v1.6.39 https://github.com/glennrp/libpng && cd libpng cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH cmake --build build -j$(nproc) cmake --build build --target install @@ -32,9 +32,24 @@ if [ ! -d libsndfile-1.2.0-win64 ]; then cp "libsndfile-1.2.0-win64/lib/sndfile.lib" $TEMP_PATH/lib fi +find_dll() { + filename=$(x86_64-w64-mingw32-gcc -print-file-name=$1) + if [ -f $filename ]; then + echo $filename + else + filename=$(x86_64-w64-mingw32-gcc -print-sysroot)/mingw/bin/$1 + if [ -f $filename ]; then + echo $filename + else + echo "Could not find $1" >&2 + return 1 + fi + fi +} + # Copy required GCC libs -cp $(find /usr | grep libgcc_s_seh-1.dll | head -n 1) $TEMP_PATH/bin -cp $(find /usr | grep libwinpthread-1.dll | head -n 1) $TEMP_PATH/bin +cp $(find_dll file-name=libgcc_s_seh-1.dll) $TEMP_PATH/bin +cp $(find_dll file-name=libwinpthread-1.dll) $TEMP_PATH/bin # Build aptdec cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH From ccfb6074ccda336206ba033dbe1c70bd73124ec9 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sun, 22 Jan 2023 13:47:53 +0000 Subject: [PATCH 08/19] Fix typo --- build_windows.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_windows.sh b/build_windows.sh index 40bf725..8ec2a7d 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -48,8 +48,8 @@ find_dll() { } # Copy required GCC libs -cp $(find_dll file-name=libgcc_s_seh-1.dll) $TEMP_PATH/bin -cp $(find_dll file-name=libwinpthread-1.dll) $TEMP_PATH/bin +cp $(find_dll libgcc_s_seh-1.dll) $TEMP_PATH/bin +cp $(find_dll libwinpthread-1.dll) $TEMP_PATH/bin # Build aptdec cmake -B $BUILD_DIR -DCMAKE_BUILD_TYPE=$1 -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH From 6b2e9b981fb2ae17f2c9471e8b6b15a6315fa6c7 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Sun, 22 Jan 2023 20:09:34 +0000 Subject: [PATCH 09/19] Fix MSVC build --- README.md | 11 ++++---- aptdec-cli/main.c | 4 +-- aptdec-cli/util.h | 4 +++ build_windows.bat | 58 +++++++++++++++++++------------------- build_windows.sh | 2 +- libaptdec/dsp.c | 13 ++++----- libaptdec/effects.c | 3 +- libaptdec/filter.c | 4 +++ libaptdec/image.c | 7 +++-- libaptdec/include/aptdec.h | 8 ++++-- 10 files changed, 63 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 1d8acab..d7618bf 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,10 @@ aptdec-cli -i lut -l luts/WXtoImg-N18-HVC.png gqrx_20200527_115730_137914960.wav ### Arguments ``` --h, --help show a help message and exit --i, --image= set output image type (see below) --e, --effect= add an effect (see below) --g, --gamma= gamma adjustment (1.0 = off) --s, --satellite= satellite ID, must be between 15, 18 or 19 or NORAD +-h, --help show this help message and exit +-i, --image= set output image type (see the README for a list) +-e, --effect= add an effect (see the README for a list) +-s, --satellite= satellite ID, must be either NORAD or 15/18/19 -l, --lut= path to a LUT -o, --output= path of output image -r, --realtime decode in realtime @@ -129,7 +128,7 @@ sudo apt install wget cmake make mingw-w64 git unzip To build natively on Windows using MSVC, you will need: git, ninja and cmake. Then run: ``` -.\build_windows.bat +./build_windows.bat ``` If you only want to build libaptdec, libpng and libsndfile aren't needed. diff --git a/aptdec-cli/main.c b/aptdec-cli/main.c index 7441354..316a700 100644 --- a/aptdec-cli/main.c +++ b/aptdec-cli/main.c @@ -110,7 +110,7 @@ int main(int argc, const char **argv) { OPT_STRING('i', "image", &opts.type, "set output image type (see the README for a list)", NULL, 0, 0), OPT_STRING('e', "effect", &opts.effects, "add an effect (see the README for a list)", NULL, 0, 0), OPT_GROUP("Satellite options"), - OPT_INTEGER('s', "satellite", &opts.satellite, "satellite ID, must be either NORAD or between 15 and 19", NULL, 0, 0), + OPT_INTEGER('s', "satellite", &opts.satellite, "satellite ID, must be either NORAD or 15/18/19", NULL, 0, 0), OPT_GROUP("Paths"), OPT_STRING('l', "lut", &opts.lut, "path to a LUT", NULL, 0, 0), OPT_STRING('o', "output", &opts.filename, "path of output image", NULL, 0, 0), @@ -454,7 +454,7 @@ static size_t callback(float *samples, size_t count, void *context) { case 1: return sf_read_float(file->file, samples, count); case 2: { - float _samples[count * 2]; + float _samples[APTDEC_BUFFER_SIZE * 2]; size_t read = sf_read_float(file->file, _samples, count * 2); for (size_t i = 0; i < count; i++) { diff --git a/aptdec-cli/util.h b/aptdec-cli/util.h index c8ab688..1ab9984 100644 --- a/aptdec-cli/util.h +++ b/aptdec-cli/util.h @@ -22,7 +22,11 @@ #include void error_noexit(const char *text); +#ifdef _MSC_VER +void error(const char *text); +#else __attribute__((noreturn)) void error(const char *text); +#endif void warning(const char *text); int clamp_int(int x, int lo, int hi); diff --git a/build_windows.bat b/build_windows.bat index 259beaa..3f995cf 100644 --- a/build_windows.bat +++ b/build_windows.bat @@ -1,36 +1,36 @@ -REM Build using Visual Studio 2019 on Windows -REM Additional tools needed: git, cmake and ninja +REM Build using MSVC on Windows +REM Requires: git, cmake and ninja REM Build zlib -git clone -b v1.2.13 https://github.com/madler/zlib -cd zlib -mkdir build -cd build -cmake -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../winpath .. -ninja install -cd ../../ +IF NOT EXIST zlib ( + git clone -b v1.2.13 https://github.com/madler/zlib + cd zlib + cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath + cmake --build build -j4 + cmake --build build --target install + cd .. +) REM Build libpng -git clone -b v1.6.39 https://github.com/glennrp/libpng -cd libpng -mkdir build -cd build -cmake -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../winpath .. -ninja install -cd ../.. +IF NOT EXIST libpng ( + git clone -b v1.6.39 https://github.com/glennrp/libpng + cd libpng + cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -DPNG_STATIC=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF + cmake --build build -j4 + cmake --build build --target install + cd .. +) -REM Build libsndfile - Could build Vorbis, FLAC and Opus first for extra support -git clone -b 1.1.0 https://github.com/libsndfile/libsndfile -cd libsndfile -mkdir build -cd build -cmake -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../../winpath .. -ninja install -cd ../.. +REM Build libsndfile, only with WAV support +IF NOT EXIST libsndfile ( + git clone -b 1.2.0 https://github.com/libsndfile/libsndfile + cd libsndfile + cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -BUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -DBUILD_PROGRAMS=OFF + cmake --build build -j4 + cmake --build build --target install + cd .. +) REM Build aptdec -mkdir winbuild -cd winbuild -cmake -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath .. -ninja install -cd .. +cmake -B winbuild -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath +cmake --build winbuil -j4 diff --git a/build_windows.sh b/build_windows.sh index 8ec2a7d..151524c 100755 --- a/build_windows.sh +++ b/build_windows.sh @@ -17,7 +17,7 @@ fi # Build libpng from source if [ ! -d "libpng" ]; then git clone --depth 1 -b v1.6.39 https://github.com/glennrp/libpng && cd libpng - cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH + cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH -DPNG_STATIC=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF cmake --build build -j$(nproc) cmake --build build --target install cd .. diff --git a/libaptdec/dsp.c b/libaptdec/dsp.c index 3c5f486..59c969c 100644 --- a/libaptdec/dsp.c +++ b/libaptdec/dsp.c @@ -27,7 +27,6 @@ #include "util.h" #include "algebra.h" -#define BUFFER_SIZE 16384 #define LOW_PASS_SIZE 101 #define CARRIER_FREQ 2400.0f @@ -113,7 +112,7 @@ aptdec_t *aptdec_init(float sample_rate) { } // Hilbert transform - apt->hilbert = fir_init(BUFFER_SIZE, 31); + apt->hilbert = fir_init(APTDEC_BUFFER_SIZE, 31); if (apt->hilbert == NULL) { free(apt->pll); free(apt); @@ -163,18 +162,18 @@ static int am_demod(aptdec_t *apt, float *out, size_t count, aptdec_callback_t c } static int get_pixels(aptdec_t *apt, float *out, size_t count, aptdec_callback_t callback, void *context) { - static float buffer[BUFFER_SIZE]; - static size_t n = BUFFER_SIZE; + static float buffer[APTDEC_BUFFER_SIZE]; + static size_t n = APTDEC_BUFFER_SIZE; static float offset = 0.0; float ratio = apt->sample_rate / (4160.0f * apt->sync_frequency); for (size_t i = 0; i < count; i++) { // Get more samples if there are less than `LOW_PASS_SIZE` available - if (n + LOW_PASS_SIZE > BUFFER_SIZE) { - memcpy(buffer, &buffer[n], (BUFFER_SIZE-n) * sizeof(float)); + if (n + LOW_PASS_SIZE > APTDEC_BUFFER_SIZE) { + memcpy(buffer, &buffer[n], (APTDEC_BUFFER_SIZE-n) * sizeof(float)); - size_t read = am_demod(apt, &buffer[BUFFER_SIZE-n], n, callback, context); + size_t read = am_demod(apt, &buffer[APTDEC_BUFFER_SIZE-n], n, callback, context); if (read != n) { return i; } diff --git a/libaptdec/effects.c b/libaptdec/effects.c index f8eff14..e48e584 100644 --- a/libaptdec/effects.c +++ b/libaptdec/effects.c @@ -138,7 +138,7 @@ int apt_crop(apt_image_t *img) { const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; - float spc_rows[img->rows]; + float *spc_rows = (float *)malloc(img->rows * sizeof(float)); int startCrop = 0; int endCrop = img->rows; @@ -171,5 +171,6 @@ int apt_crop(apt_image_t *img) { // Remove the noisy rows at start memmove(img->data, &img->data[startCrop * APT_IMG_WIDTH], img->rows * APT_IMG_WIDTH * sizeof(float)); + free(spc_rows); return startCrop; } diff --git a/libaptdec/filter.c b/libaptdec/filter.c index e45fbf8..732d741 100644 --- a/libaptdec/filter.c +++ b/libaptdec/filter.c @@ -98,7 +98,11 @@ complexf_t hilbert_transform(const float *in, const float *taps, size_t len) { } float interpolating_convolve(const float *in, const float *taps, size_t len, float offset) { +#ifdef _MSC_VER + float *_taps = (float *)_alloca(len * sizeof(float)); +#else float _taps[len]; +#endif for (size_t i = 0; i < len; i++) { float next = (i == len-1) ? 0.0f : taps[i+1]; diff --git a/libaptdec/image.c b/libaptdec/image.c index 7093563..5982c7d 100644 --- a/libaptdec/image.c +++ b/libaptdec/image.c @@ -38,7 +38,7 @@ apt_image_t apt_image_clone(apt_image_t img) { static void decode_telemetry(const float *data, size_t rows, size_t offset, float *wedges) { // Calculate row average - float telemetry_rows[rows]; + float *telemetry_rows = (float *)malloc(rows * sizeof(float)); for (size_t y = 0; y < rows; y++) { telemetry_rows[y] = meanf(&data[y*APT_IMG_WIDTH + offset + APT_CH_WIDTH], APT_TELEMETRY_WIDTH); } @@ -74,10 +74,12 @@ static void decode_telemetry(const float *data, size_t rows, size_t offset, floa for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { wedges[i] = meanf(&telemetry_rows[best_frame + i*APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT); } + + free(telemetry_rows); } static float average_spc(apt_image_t *img, size_t offset) { - float rows[img->rows]; + float *rows = (float *)malloc(img->rows * sizeof(float)); float average = 0.0f; for (size_t y = 0; y < img->rows; y++) { float row_average = 0.0f; @@ -100,6 +102,7 @@ static float average_spc(apt_image_t *img, size_t offset) { } } + free(rows); return weighted_average / (float)n; } diff --git a/libaptdec/include/aptdec.h b/libaptdec/include/aptdec.h index 669537c..9d3cc5b 100644 --- a/libaptdec/include/aptdec.h +++ b/libaptdec/include/aptdec.h @@ -64,6 +64,8 @@ extern "C" { // Number of rows needed for apt_normalize to (reliably) work #define APTDEC_NORMALIZE_ROWS (APT_FRAME_LEN * 2) +// Maximum amount of samples that will be requested from aptdec_callback_t +#define APTDEC_BUFFER_SIZE 16384 // Channel 1: visible (0.58-0.68 um) // Channel 2: near-IR (0.725-1.0 um) @@ -115,7 +117,7 @@ typedef size_t (*aptdec_callback_t)(float *samples, size_t count, void *context) // Clone an apt_image_t struct // Useful for calibration -apt_image_t apt_image_clone(apt_image_t img); +APTDEC_API apt_image_t apt_image_clone(apt_image_t img); // Returns version of libaptdec in git tag format // i.e. v2.0.0 or v2.0.0-1-xxxxxx @@ -159,8 +161,8 @@ static const apt_region_t APT_REGION_CHA_FULL = { 0, APT_IMG_WIDTH static const apt_region_t APT_REGION_CHB_FULL = { APT_IMG_WIDTH/2, APT_IMG_WIDTH/2 }; static const apt_region_t APT_REGION_FULL = { 0, APT_IMG_WIDTH }; -extern const uint32_t temperature_gradient[256]; -extern const uint32_t precipitation_gradient[58]; +APTDEC_API extern const uint32_t temperature_gradient[256]; +APTDEC_API extern const uint32_t precipitation_gradient[58]; #ifdef __cplusplus } From c551e7033513369e1cc57b0473d9ee2712b5e163 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 14:21:56 +0000 Subject: [PATCH 10/19] Include missing header and fix stddev Standard deviation on a non complete population sample is divided by n-1, not n --- libaptdec/algebra.c | 9 +++------ libaptdec/effects.c | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libaptdec/algebra.c b/libaptdec/algebra.c index e922a1e..20f4160 100644 --- a/libaptdec/algebra.c +++ b/libaptdec/algebra.c @@ -52,12 +52,9 @@ linear_t linear_regression(const float *independent, const float *dependent, siz return (linear_t){a, b}; } +// "Sample" standard deviation float standard_deviation(const float *data, size_t len) { - float mean = 0.0f; - for (size_t i = 0; i < len; i++) { - mean += data[i]; - } - mean /= (float)len; + float mean = meanf(data, len); float deviation_mean = 0.0f; for (size_t i = 0; i < len; i++) { @@ -65,7 +62,7 @@ float standard_deviation(const float *data, size_t len) { deviation_mean += deviation * deviation; } - return sqrtf(deviation_mean / (float)len); + return sqrtf(deviation_mean / (float)(len-1)); } float sumf(const float *x, size_t len) { diff --git a/libaptdec/effects.c b/libaptdec/effects.c index e48e584..61ab0ae 100644 --- a/libaptdec/effects.c +++ b/libaptdec/effects.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "algebra.h" #include "util.h" From 711d0e0163862da8a1ca3472d200c0617981a4e1 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 14:22:55 +0000 Subject: [PATCH 11/19] MSVC build in GitHub actions --- .github/workflows/build.yml | 18 ++++++++++++++++++ build_windows.bat | 24 +++++++++++++----------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c4acba6..b568ae3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,3 +61,21 @@ jobs: with: name: ZIP package path: winbuild/aptdec_*.zip + + build_windows_msvc: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: Run build script + run: vcvarsx86_amd64 & ./build_windows.bat + + - name: Upload ZIP package + uses: actions/upload-artifact@v3 + with: + name: ZIP package (MSVC) + path: winbuild/aptdec_*.zip diff --git a/build_windows.bat b/build_windows.bat index 3f995cf..133d153 100644 --- a/build_windows.bat +++ b/build_windows.bat @@ -1,36 +1,38 @@ REM Build using MSVC on Windows REM Requires: git, cmake and ninja +REM You need to run vcvars before running this REM Build zlib IF NOT EXIST zlib ( - git clone -b v1.2.13 https://github.com/madler/zlib + git clone --depth 1 -b v1.2.13 https://github.com/madler/zlib cd zlib - cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath - cmake --build build -j4 + cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath + cmake --build build -j%NUMBER_OF_PROCESSORS% cmake --build build --target install cd .. ) REM Build libpng IF NOT EXIST libpng ( - git clone -b v1.6.39 https://github.com/glennrp/libpng + git clone --depth 1 -b v1.6.39 https://github.com/glennrp/libpng cd libpng - cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -DPNG_STATIC=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF - cmake --build build -j4 + cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -DPNG_STATIC=OFF -DPNG_EXECUTABLES=OFF -DPNG_TESTS=OFF + cmake --build build -j%NUMBER_OF_PROCESSORS% cmake --build build --target install cd .. ) REM Build libsndfile, only with WAV support IF NOT EXIST libsndfile ( - git clone -b 1.2.0 https://github.com/libsndfile/libsndfile + git clone --depth 1 -b 1.2.0 https://github.com/libsndfile/libsndfile cd libsndfile - cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -BUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -DBUILD_PROGRAMS=OFF - cmake --build build -j4 + cmake -B build -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -DBUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -DBUILD_PROGRAMS=OFF + cmake --build build -j%NUMBER_OF_PROCESSORS% cmake --build build --target install cd .. ) REM Build aptdec -cmake -B winbuild -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DMSVC_TOOLSET_VERSION=190 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath -cmake --build winbuil -j4 +cmake -B winbuild -G Ninja -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../winpath +cmake --build winbuild -j%NUMBER_OF_PROCESSORS% +cmake --build winbuild --target package From 8c6cba0aa3f62ce810ae479970f1309bc7b9dfdc Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 18:02:44 +0000 Subject: [PATCH 12/19] ARM builds --- .github/workflows/build.yml | 27 ++++++++++++++++++++++++++- .gitignore | 1 + CMakeLists.txt | 5 +++-- build_arm.sh | 18 ++++++++++++++++++ cmake/toolchain-armhf.cmake | 19 +++++++++++++++++++ 5 files changed, 67 insertions(+), 3 deletions(-) create mode 100755 build_arm.sh create mode 100644 cmake/toolchain-armhf.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b568ae3..590b755 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,10 +72,35 @@ jobs: fetch-depth: 0 - name: Run build script - run: vcvarsx86_amd64 & ./build_windows.bat + shell: cmd + run: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" & build_windows.bat - name: Upload ZIP package uses: actions/upload-artifact@v3 with: name: ZIP package (MSVC) path: winbuild/aptdec_*.zip + + build_linux_armhf: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: 'recursive' + fetch-depth: 0 + + - name: Run build script + run: docker run -v $(pwd):/aptdec:z -w /aptdec debian:11 ./build_arm.sh + + - name: Upload DEB package + uses: actions/upload-artifact@v3 + with: + name: DEB package (ARM) + path: build/aptdec_*.deb + + - name: Upload TGZ package + uses: actions/upload-artifact@v3 + with: + name: TGZ package (ARM) + path: build/aptdec_*.tar.gz diff --git a/.gitignore b/.gitignore index d4e410a..0febd33 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,4 @@ zlib/ libpng/ libsndfile-*-win64.zip libsndfile-*-win64/ +root/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e5f3a09..4c99a00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,13 +79,14 @@ endif() install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) # Packaging -set(CPACK_PACKAGE_VERSION "${VERSION}") +string(REPLACE v "" CPACK_PACKAGE_VERSION ${VERSION}) +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) set(CPACK_PACKAGE_NAME "aptdec") set(CPACK_PACKAGE_CONTACT "Xerbo (xerbo@protonmail.com)") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "NOAA APT satellite imagery decoder") set(CPACK_PACKAGE_DESCRIPTION "Aptdec is a FOSS library/program that decodes images transmitted by the NOAA POES weather satellites. These satellites transmit constantly (among other things) medium resolution (4km/px) images of the earth over a analog mode called APT.") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.${CMAKE_SYSTEM_PROCESSOR}") -set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsndfile1, libpng16-16") if(WIN32) file(GLOB DLLS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/*.dll) diff --git a/build_arm.sh b/build_arm.sh new file mode 100755 index 0000000..7c44c9c --- /dev/null +++ b/build_arm.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# This script only works on Debian Bullseye +# If you have docker this is trivially easy: +# docker run -v $(pwd):/aptdec:z -w /aptdec debian:11 ./build_arm.sh + +apt-get update +apt-get install -y debootstrap cmake gcc-arm-linux-gnueabihf + +# Prepare armhf root environment +if [ ! -d root ]; then + debootstrap --keyring=/usr/share/keyrings/debian-archive-keyring.gpg --arch=armhf --include=libsndfile1-dev,libpng-dev --download-only bullseye root http://deb.debian.org/debian/ + for i in root/var/cache/apt/archives/*.deb; do dpkg -x "$i" root; done +fi + +# Build aptdec +cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain-armhf.cmake -DCMAKE_INSTALL_PREFIX=/aptdec/root +cmake --build build -j$(nproc) +cmake --build build --target package diff --git a/cmake/toolchain-armhf.cmake b/cmake/toolchain-armhf.cmake new file mode 100644 index 0000000..6e5a70a --- /dev/null +++ b/cmake/toolchain-armhf.cmake @@ -0,0 +1,19 @@ +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_PROCESSOR armhf) + +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc) +SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf/ ${CMAKE_INSTALL_PREFIX}) +# Hack +link_directories(${CMAKE_INSTALL_PREFIX}/lib/arm-linux-gnueabihf) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) From 61ec605ffd9f22b1cc3a4072aa2a022cf09f27fe Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 18:04:39 +0000 Subject: [PATCH 13/19] Fix syntax --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 590b755..acbbe7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,7 +73,7 @@ jobs: - name: Run build script shell: cmd - run: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" & build_windows.bat + run: '"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" & build_windows.bat' - name: Upload ZIP package uses: actions/upload-artifact@v3 From c9d89ea21039beff7d37c473960f72b6bc9a556d Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 18:16:18 +0000 Subject: [PATCH 14/19] Better naming --- .github/ISSUE_TEMPLATE/bug-report.md | 5 ++-- .github/workflows/build.yml | 24 ++++++++++---------- UPGRADE_GUIDE.md | 34 ++++++++++++++++++++++++++++ cmake/toolchain-mingw32.cmake | 2 +- 4 files changed, 49 insertions(+), 16 deletions(-) create mode 100644 UPGRADE_GUIDE.md diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 41036f7..e85e0a7 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -4,7 +4,6 @@ about: Create a bug report to improve aptdec title: '' labels: bug assignees: '' - --- **Describe the bug** @@ -17,7 +16,7 @@ Steps to reproduce the behavior. A clear description of what you expected to happen. **Link to audio** -A link to the audio that caused the problem. +A link to the audio file that caused the problem (if applicable). **Build information** -The commit of aptdec you are running (check with `git rev-parse HEAD`), make sure it's up to date before opening this issue. +The version of aptdec you are running (check with `git describe --tag`), make sure it's up to date before opening this issue. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index acbbe7b..a692a35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,16 +29,16 @@ jobs: - name: Build and package run: cmake --build build -j$(nproc) && cmake --build build --target package - - name: Upload TGZ package + - name: Upload TGZ archive uses: actions/upload-artifact@v3 with: - name: TGZ package + name: TGZ archive (x86_64/gcc) path: build/aptdec_*.tar.gz - - name: Upload DEB package + - name: Upload Debian package uses: actions/upload-artifact@v3 with: - name: Debian package + name: Debian package (x86_64/gcc) path: build/aptdec_*.deb build_windows: @@ -56,10 +56,10 @@ jobs: - name: Run build script run: ./build_windows.sh $BUILD_TYPE - - name: Upload ZIP package + - name: Upload ZIP archive uses: actions/upload-artifact@v3 with: - name: ZIP package + name: ZIP archive (x86_64/MinGW) path: winbuild/aptdec_*.zip build_windows_msvc: @@ -75,10 +75,10 @@ jobs: shell: cmd run: '"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" & build_windows.bat' - - name: Upload ZIP package + - name: Upload ZIP archive uses: actions/upload-artifact@v3 with: - name: ZIP package (MSVC) + name: ZIP archive (x86_64/MSVC) path: winbuild/aptdec_*.zip build_linux_armhf: @@ -93,14 +93,14 @@ jobs: - name: Run build script run: docker run -v $(pwd):/aptdec:z -w /aptdec debian:11 ./build_arm.sh - - name: Upload DEB package + - name: Upload Debian package uses: actions/upload-artifact@v3 with: - name: DEB package (ARM) + name: Debian package (armhf/gcc) path: build/aptdec_*.deb - - name: Upload TGZ package + - name: Upload TGZ archive uses: actions/upload-artifact@v3 with: - name: TGZ package (ARM) + name: TGZ archive (armhf/gcc) path: build/aptdec_*.tar.gz diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md new file mode 100644 index 0000000..0db0041 --- /dev/null +++ b/UPGRADE_GUIDE.md @@ -0,0 +1,34 @@ +# Upgrading from aptdec 1.8.0 to 2.0.0 + +# `aptdec` (now `aptdec-cli`) + +## Removed + +- The `-d` (output directory) flag +- The `-g` (gamma) flag +- Map overlays/MCIR +- Reading raw PNG images + +(Some of these features have been moved into `aptdec_post.py`) + +## Changes + +- "palettes" are now called "luts" +- Image type and effects are now full English words (separated by commas) instead of letters +- Output format of realtime images is now `CURRENT_TIME.png` instead of `CURRENT_TIME-r.png` +- Channel A/B images include telemetry + +## Examples + +| v1.8 | v2.0.0 | +|---------------------------------------|-------------------------------------------| +| `aptdec file.wav` | `aptdec-cli file.wav` | +| `aptdec -i rt file.wav` | `aptdec-cli -i raw,thermal file.wav` | +| `aptdec -i ab file.wav` | `aptdec-cli -i a,b -e strip file.wav` | +| `aptdec -i p -p palette.png file.wav` | `aptdec-cli -i lut -l lut.png file.wav` | +| `aptdec -d out *.wav` | `mkdir out; cd out; aptdec-cli ../*.wav` | + + +# `libapt` (now `libaptdec`) + +To avoid confusion with `apt` (the Debian package manager) the name of the aptdec library has been changed to `libaptdec`. diff --git a/cmake/toolchain-mingw32.cmake b/cmake/toolchain-mingw32.cmake index de03f7e..464fb89 100644 --- a/cmake/toolchain-mingw32.cmake +++ b/cmake/toolchain-mingw32.cmake @@ -1,6 +1,6 @@ # the name of the target operating system SET(CMAKE_SYSTEM_NAME Windows) -SET(CMAKE_SYSTEM_PROCESSOR amd64) +SET(CMAKE_SYSTEM_PROCESSOR x86_64) # which compilers to use for C and C++ SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) From 071a9c8f842ae4604b13c1e1b611ce2b52acc6a2 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 18:18:41 +0000 Subject: [PATCH 15/19] Better naming, but valid this time --- .github/workflows/build.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a692a35..893e061 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,13 +32,13 @@ jobs: - name: Upload TGZ archive uses: actions/upload-artifact@v3 with: - name: TGZ archive (x86_64/gcc) + name: TGZ archive (x86_64-gcc) path: build/aptdec_*.tar.gz - name: Upload Debian package uses: actions/upload-artifact@v3 with: - name: Debian package (x86_64/gcc) + name: Debian package (x86_64-gcc) path: build/aptdec_*.deb build_windows: @@ -59,7 +59,7 @@ jobs: - name: Upload ZIP archive uses: actions/upload-artifact@v3 with: - name: ZIP archive (x86_64/MinGW) + name: ZIP archive (x86_64-MinGW) path: winbuild/aptdec_*.zip build_windows_msvc: @@ -78,7 +78,7 @@ jobs: - name: Upload ZIP archive uses: actions/upload-artifact@v3 with: - name: ZIP archive (x86_64/MSVC) + name: ZIP archive (x86_64-MSVC) path: winbuild/aptdec_*.zip build_linux_armhf: @@ -96,11 +96,11 @@ jobs: - name: Upload Debian package uses: actions/upload-artifact@v3 with: - name: Debian package (armhf/gcc) + name: Debian package (armhf-gcc) path: build/aptdec_*.deb - name: Upload TGZ archive uses: actions/upload-artifact@v3 with: - name: TGZ archive (armhf/gcc) + name: TGZ archive (armhf-gcc) path: build/aptdec_*.tar.gz From 66b8dd026e59e9b9b4733370b4d604b01bbec316 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 20:48:17 +0000 Subject: [PATCH 16/19] Fix memory leak and move state entirely into aptdec_t --- aptdec-cli/main.c | 1 + libaptdec/dsp.c | 54 +++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/aptdec-cli/main.c b/aptdec-cli/main.c index 316a700..7fe5413 100644 --- a/aptdec-cli/main.c +++ b/aptdec-cli/main.c @@ -244,6 +244,7 @@ static int process_file(const char *path, options_t *opts) { // Normalize int error; apt_image_t img = apt_normalize(data, rows, opts->satellite, &error); + free(data); if (error) { error_noexit("Normalization failed"); return 0; diff --git a/libaptdec/dsp.c b/libaptdec/dsp.c index 59c969c..1bc2af1 100644 --- a/libaptdec/dsp.c +++ b/libaptdec/dsp.c @@ -32,6 +32,10 @@ #define CARRIER_FREQ 2400.0f #define MAX_CARRIER_OFFSET 10.0f +const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, + 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; +#define SYNC_SIZE (sizeof(sync_pattern)/sizeof(sync_pattern[0])) + typedef struct { float alpha; float beta; @@ -58,6 +62,11 @@ struct aptdec_t { fir_t *hilbert; float low_pass[LOW_PASS_SIZE]; + float row_buffer[APT_IMG_WIDTH + SYNC_SIZE + 2]; + + float interpolator_buffer[APTDEC_BUFFER_SIZE]; + size_t interpolator_n; + float interpolator_offset; }; char *aptdec_get_version(void) { @@ -162,47 +171,38 @@ static int am_demod(aptdec_t *apt, float *out, size_t count, aptdec_callback_t c } static int get_pixels(aptdec_t *apt, float *out, size_t count, aptdec_callback_t callback, void *context) { - static float buffer[APTDEC_BUFFER_SIZE]; - static size_t n = APTDEC_BUFFER_SIZE; - static float offset = 0.0; - float ratio = apt->sample_rate / (4160.0f * apt->sync_frequency); for (size_t i = 0; i < count; i++) { // Get more samples if there are less than `LOW_PASS_SIZE` available - if (n + LOW_PASS_SIZE > APTDEC_BUFFER_SIZE) { - memcpy(buffer, &buffer[n], (APTDEC_BUFFER_SIZE-n) * sizeof(float)); + if (apt->interpolator_n + LOW_PASS_SIZE > APTDEC_BUFFER_SIZE) { + memcpy(apt->interpolator_buffer, &apt->interpolator_buffer[apt->interpolator_n], (APTDEC_BUFFER_SIZE-apt->interpolator_n) * sizeof(float)); - size_t read = am_demod(apt, &buffer[APTDEC_BUFFER_SIZE-n], n, callback, context); - if (read != n) { + size_t read = am_demod(apt, &apt->interpolator_buffer[APTDEC_BUFFER_SIZE-apt->interpolator_n], apt->interpolator_n, callback, context); + if (read != apt->interpolator_n) { return i; } - n = 0; + apt->interpolator_n = 0; } - out[i] = interpolating_convolve(&buffer[n], apt->low_pass, LOW_PASS_SIZE, offset); + out[i] = interpolating_convolve(&apt->interpolator_buffer[apt->interpolator_n], apt->low_pass, LOW_PASS_SIZE, apt->interpolator_offset); // Do not question the sacred code - int shift = ceilf(ratio - offset); - offset = shift + offset - ratio; - n += shift; + int shift = ceilf(ratio - apt->interpolator_offset); + apt->interpolator_offset = shift + apt->interpolator_offset - ratio; + apt->interpolator_n += shift; } return count; } -const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, - 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; -#define SYNC_SIZE (sizeof(sync_pattern)/sizeof(sync_pattern[0])) - // Get an entire row of pixels, aligned with sync markers int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *context) { - static float pixels[APT_IMG_WIDTH + SYNC_SIZE + 2]; - // Wrap the circular buffer - memcpy(pixels, &pixels[APT_IMG_WIDTH], (SYNC_SIZE + 2) * sizeof(float)); + memcpy(apt->row_buffer, &apt->row_buffer[APT_IMG_WIDTH], (SYNC_SIZE + 2) * sizeof(float)); + // Get a lines worth (APT_IMG_WIDTH) of samples - if (get_pixels(apt, &pixels[SYNC_SIZE + 2], APT_IMG_WIDTH, callback, context) != APT_IMG_WIDTH) { + if (get_pixels(apt, &apt->row_buffer[SYNC_SIZE + 2], APT_IMG_WIDTH, callback, context) != APT_IMG_WIDTH) { return 0; } @@ -213,9 +213,9 @@ int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *c size_t phase = 0; for (size_t i = 0; i < APT_IMG_WIDTH; i++) { - float _left = convolve(&pixels[i + 0], sync_pattern, SYNC_SIZE); - float _middle = convolve(&pixels[i + 1], sync_pattern, SYNC_SIZE); - float _right = convolve(&pixels[i + 2], sync_pattern, SYNC_SIZE); + float _left = convolve(&apt->row_buffer[i + 0], sync_pattern, SYNC_SIZE); + float _middle = convolve(&apt->row_buffer[i + 1], sync_pattern, SYNC_SIZE); + float _right = convolve(&apt->row_buffer[i + 2], sync_pattern, SYNC_SIZE); if (_middle > middle) { left = _left; middle = _middle; @@ -226,11 +226,11 @@ int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *c // Frequency float bias = (left / middle) - (right / middle); - apt->sync_frequency = 1.0f + bias / APT_IMG_WIDTH / 2.0f; + apt->sync_frequency = 1.0f + bias / APT_IMG_WIDTH / 4.0f; // Phase - memcpy(&row[APT_IMG_WIDTH], &pixels[phase], (APT_IMG_WIDTH - phase) * sizeof(float)); - memcpy(&row[APT_IMG_WIDTH - phase], pixels, phase * sizeof(float)); + memcpy(&row[APT_IMG_WIDTH], &apt->row_buffer[phase], (APT_IMG_WIDTH - phase) * sizeof(float)); + memcpy(&row[APT_IMG_WIDTH - phase], apt->row_buffer, phase * sizeof(float)); return 1; } From e1c117395995bab414914cb94865ee197b96ba04 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Tue, 24 Jan 2023 22:24:47 +0000 Subject: [PATCH 17/19] Implement strip effect --- CMakeLists.txt | 2 +- aptdec-cli/main.c | 58 ++++++++++++++++++++++++++++++++++++++++++----- build_arm.sh | 2 +- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c99a00..6b59dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,7 +76,7 @@ else() target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() -install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) # Packaging string(REPLACE v "" CPACK_PACKAGE_VERSION ${VERSION}) diff --git a/aptdec-cli/main.c b/aptdec-cli/main.c index 7fe5413..581933f 100644 --- a/aptdec-cli/main.c +++ b/aptdec-cli/main.c @@ -67,6 +67,8 @@ static int freq_from_filename(const char *filename); static int satid_from_freq(int freq); static size_t callback(float *samples, size_t count, void *context); static void write_line(writer_t *png, float *row); +apt_image_t strip(apt_image_t img); +int array_contains(char **array, char *value, size_t n); static volatile int sigint_stop = 0; void sigint_handler(int signum) { @@ -361,8 +363,16 @@ static int process_file(const char *path, options_t *opts) { channel_desc[img.ch[1]] ); - writer_t *writer = writer_init(filename, APT_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); - writer_write_image(writer, &img); + writer_t *writer; + if (array_contains(effects, "strip", effects_len)) { + writer = writer_init(filename, (apt_region_t){0, APT_CH_WIDTH*2}, img.rows, PNG_COLOR_TYPE_GRAY, description); + apt_image_t _img = strip(img); + writer_write_image(writer, &_img); + free(_img.data); + } else { + writer = writer_init(filename, APT_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &img); + } writer_free(writer); } else if (strcmp(images[i], "lut") == 0) { if (opts->lut != NULL && opts->lut[0] != '\0') { @@ -393,8 +403,16 @@ static int process_file(const char *path, options_t *opts) { char description[128]; sprintf(description, "Channel A: %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]); - writer_t *writer = writer_init(filename, APT_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); - writer_write_image(writer, &img); + writer_t *writer; + if (array_contains(effects, "strip", effects_len)) { + writer = writer_init(filename, (apt_region_t){0, APT_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description); + apt_image_t _img = strip(img); + writer_write_image(writer, &_img); + free(_img.data); + } else { + writer = writer_init(filename, APT_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &img); + } writer_free(writer); } else if (strcmp(images[i], "b") == 0) { char filename[269]; @@ -402,8 +420,16 @@ static int process_file(const char *path, options_t *opts) { char description[128]; sprintf(description, "Channel B: %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]); - writer_t *writer = writer_init(filename, APT_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); - writer_write_image(writer, &img); + writer_t *writer; + if (array_contains(effects, "strip", effects_len)) { + writer = writer_init(filename, (apt_region_t){APT_CH_WIDTH, APT_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description); + apt_image_t _img = strip(img); + writer_write_image(writer, &_img); + free(_img.data); + } else { + writer = writer_init(filename, APT_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_write_image(writer, &img); + } writer_free(writer); } } @@ -489,3 +515,23 @@ static void write_line(writer_t *png, float *row) { png_write_row(png->png, pixels); #pragma GCC diagnostic pop } + +apt_image_t strip(apt_image_t img) { + uint8_t *data = (uint8_t *)malloc(img.rows * APT_IMG_WIDTH); + for (size_t y = 0; y < img.rows; y++) { + memcpy(&data[y*APT_IMG_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHA_OFFSET], APT_CH_WIDTH); + memcpy(&data[y*APT_IMG_WIDTH + APT_CH_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHB_OFFSET], APT_CH_WIDTH); + } + + img.data = data; + return img; +} + +int array_contains(char **array, char *value, size_t n) { + for (size_t i = 0; i < n; i++) { + if (strcmp(array[i], value) == 0) { + return 1; + } + } + return 0; +} \ No newline at end of file diff --git a/build_arm.sh b/build_arm.sh index 7c44c9c..aa4034f 100755 --- a/build_arm.sh +++ b/build_arm.sh @@ -4,7 +4,7 @@ # docker run -v $(pwd):/aptdec:z -w /aptdec debian:11 ./build_arm.sh apt-get update -apt-get install -y debootstrap cmake gcc-arm-linux-gnueabihf +apt-get install -y debootstrap cmake gcc-arm-linux-gnueabihf git # Prepare armhf root environment if [ ! -d root ]; then From b2b049f727402b6b8a6ac42340e58c5465e1af79 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Wed, 25 Jan 2023 20:37:55 +0000 Subject: [PATCH 18/19] Initialize memory before use --- aptdec-cli/main.c | 40 ++++++++++++++++++++-------------------- aptdec-cli/pngio.c | 4 ++-- libaptdec/dsp.c | 12 +++++++----- libaptdec/effects.c | 6 +++--- libaptdec/image.c | 14 +++++++------- 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/aptdec-cli/main.c b/aptdec-cli/main.c index 581933f..c9da9e0 100644 --- a/aptdec-cli/main.c +++ b/aptdec-cli/main.c @@ -86,7 +86,7 @@ char *basename(const char *filename) { #endif int main(int argc, const char **argv) { - char version[128]; + char version[128] = { 0 }; get_version(version); printf("%s\n", version); // clang-format off @@ -166,7 +166,7 @@ int main(int argc, const char **argv) { static int process_file(const char *path, options_t *opts) { const char *path_basename = basename((char *)path); const char *dot = strrchr(path_basename, '.'); - char name[256]; + char name[256] = { 0 }; if (dot == NULL) { strncpy(name, path_basename, 255); } else { @@ -181,7 +181,7 @@ static int process_file(const char *path, options_t *opts) { writer_t *realtime_png; if (opts->realtime) { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-decoding.png", name); realtime_png = writer_init(filename, APT_REGION_FULL, APTDEC_MAX_HEIGHT, PNG_COLOR_TYPE_GRAY, "Unknown"); @@ -209,7 +209,7 @@ static int process_file(const char *path, options_t *opts) { } // Decode image - float *data = (float *)malloc(APT_IMG_WIDTH * (APTDEC_MAX_HEIGHT+1) * sizeof(float)); + float *data = calloc(APT_IMG_WIDTH * (APTDEC_MAX_HEIGHT+1), sizeof(float)); size_t rows; for (rows = 0; rows < APTDEC_MAX_HEIGHT; rows++) { float *row = &data[rows * APT_IMG_WIDTH]; @@ -238,7 +238,7 @@ static int process_file(const char *path, options_t *opts) { writer_free(realtime_png); #pragma GCC diagnostic pop - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-decoding.png", name); remove(filename); } @@ -294,9 +294,9 @@ static int process_file(const char *path, options_t *opts) { if (strcmp(images[i], "thermal") == 0) { if (img.ch[1] >= 4) { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-thermal.png", base); - char description[128]; + char description[128] = { 0 }; sprintf(description, "Calibrated thermal image, channel %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]); // Perform visible calibration @@ -313,9 +313,9 @@ static int process_file(const char *path, options_t *opts) { } } else if (strcmp(images[i], "visible") == 0) { if (img.ch[0] <= 2) { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-visible.png", base); - char description[128]; + char description[128] = { 0 }; sprintf(description, "Calibrated visible image, channel %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]); // Perform visible calibration @@ -352,9 +352,9 @@ static int process_file(const char *path, options_t *opts) { } if (strcmp(images[i], "raw") == 0) { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-raw.png", base); - char description[128]; + char description[128] = { 0 }; sprintf(description, "Raw image, channel %s - %s / %s - %s", channel_name[img.ch[0]], @@ -376,9 +376,9 @@ static int process_file(const char *path, options_t *opts) { writer_free(writer); } else if (strcmp(images[i], "lut") == 0) { if (opts->lut != NULL && opts->lut[0] != '\0') { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-lut.png", base); - char description[128]; + char description[128] = { 0 }; sprintf(description, "LUT image, channel %s - %s / %s - %s", channel_name[img.ch[0]], @@ -387,7 +387,7 @@ static int process_file(const char *path, options_t *opts) { channel_desc[img.ch[1]] ); - png_colorp lut = (png_colorp)malloc(sizeof(png_color)*256*256); + png_colorp lut = calloc(256*256, sizeof(png_color)); if (read_lut(opts->lut, lut)) { writer_t *writer = writer_init(filename, APT_REGION_CHA, img.rows, PNG_COLOR_TYPE_RGB, description); writer_write_image_lut(writer, &img, lut); @@ -398,9 +398,9 @@ static int process_file(const char *path, options_t *opts) { warning("Cannot create LUT image, missing -l/--lut"); } } else if (strcmp(images[i], "a") == 0) { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-a.png", base); - char description[128]; + char description[128] = { 0 }; sprintf(description, "Channel A: %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]); writer_t *writer; @@ -415,9 +415,9 @@ static int process_file(const char *path, options_t *opts) { } writer_free(writer); } else if (strcmp(images[i], "b") == 0) { - char filename[269]; + char filename[269] = { 0 }; sprintf(filename, "%s-b.png", base); - char description[128]; + char description[128] = { 0 }; sprintf(description, "Channel B: %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]); writer_t *writer; @@ -517,7 +517,7 @@ static void write_line(writer_t *png, float *row) { } apt_image_t strip(apt_image_t img) { - uint8_t *data = (uint8_t *)malloc(img.rows * APT_IMG_WIDTH); + uint8_t *data = calloc(img.rows * APT_IMG_WIDTH, sizeof(uint8_t)); for (size_t y = 0; y < img.rows; y++) { memcpy(&data[y*APT_IMG_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHA_OFFSET], APT_CH_WIDTH); memcpy(&data[y*APT_IMG_WIDTH + APT_CH_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHB_OFFSET], APT_CH_WIDTH); @@ -534,4 +534,4 @@ int array_contains(char **array, char *value, size_t n) { } } return 0; -} \ No newline at end of file +} diff --git a/aptdec-cli/pngio.c b/aptdec-cli/pngio.c index b267d12..c60feaf 100644 --- a/aptdec-cli/pngio.c +++ b/aptdec-cli/pngio.c @@ -25,7 +25,7 @@ #include "util.h" writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height, int color, char *channel) { - writer_t *png = (writer_t *)malloc(sizeof(writer_t)); + writer_t *png = calloc(1, sizeof(writer_t)); png->region = region; // Create writer @@ -43,7 +43,7 @@ writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height png_set_IHDR(png->png, png->info, png->region.width, height, 8, color, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - char version[128]; + char version[128] = { 0 }; int version_len = get_version(version); png_text text[] = { diff --git a/libaptdec/dsp.c b/libaptdec/dsp.c index 1bc2af1..c82a412 100644 --- a/libaptdec/dsp.c +++ b/libaptdec/dsp.c @@ -74,11 +74,11 @@ char *aptdec_get_version(void) { } fir_t *fir_init(size_t max_size, size_t ntaps) { - fir_t *fir = (fir_t *)malloc(sizeof(fir_t)); + fir_t *fir = calloc(1, sizeof(fir_t)); fir->ntaps = ntaps; fir->ring_size = max_size + ntaps; - fir->taps = (float *)malloc(ntaps * sizeof(float)); - fir->ring_buffer = (float *)malloc((max_size + ntaps) * sizeof(float)); + fir->taps = calloc(ntaps, sizeof(float)); + fir->ring_buffer = calloc(max_size + ntaps, sizeof(float)); return fir; } @@ -89,7 +89,7 @@ void fir_free(fir_t *fir) { } pll_t *pll_init(float alpha, float beta, float min_freq, float max_freq, float sample_rate) { - pll_t *pll = (pll_t *)malloc(sizeof(pll_t)); + pll_t *pll = calloc(1, sizeof(pll_t)); pll->alpha = alpha; pll->beta = beta; pll->min_freq = M_TAUf * min_freq / sample_rate; @@ -104,9 +104,11 @@ aptdec_t *aptdec_init(float sample_rate) { return NULL; } - aptdec_t *apt = (aptdec_t *)malloc(sizeof(aptdec_t)); + aptdec_t *apt = calloc(1, sizeof(aptdec_t)); apt->sample_rate = sample_rate; apt->sync_frequency = 1.0f; + apt->interpolator_n = APTDEC_BUFFER_SIZE; + apt->interpolator_offset = 0.0f; // PLL configuration // https://www.trondeau.com/blog/2011/8/13/control-loop-gain-values.html diff --git a/libaptdec/effects.c b/libaptdec/effects.c index 61ab0ae..1afec32 100644 --- a/libaptdec/effects.c +++ b/libaptdec/effects.c @@ -102,7 +102,7 @@ void apt_stretch(apt_image_t *img, apt_region_t region) { void apt_denoise(apt_image_t *img, apt_region_t region) { for (size_t y = 1; y < img->rows - 1; y++) { for (size_t x = 1; x < region.width - 1; x++) { - float pixels[9]; + float pixels[9] = { 0.0f }; int pixeln = 0; for (int y2 = -1; y2 < 2; y2++) { for (int x2 = -1; x2 < 2; x2++) { @@ -139,12 +139,12 @@ int apt_crop(apt_image_t *img) { const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; - float *spc_rows = (float *)malloc(img->rows * sizeof(float)); + float *spc_rows = calloc(img->rows, sizeof(float)); int startCrop = 0; int endCrop = img->rows; for (size_t y = 0; y < img->rows; y++) { - float temp[39]; + float temp[39] = { 0.0f }; for (size_t i = 0; i < 39; i++) { temp[i] = img->data[y * APT_IMG_WIDTH + i]; } diff --git a/libaptdec/image.c b/libaptdec/image.c index 5982c7d..e6498bd 100644 --- a/libaptdec/image.c +++ b/libaptdec/image.c @@ -21,9 +21,9 @@ #include #include #include +#include #include "algebra.h" -#include #include "util.h" #include "calibration.h" @@ -31,14 +31,14 @@ apt_image_t apt_image_clone(apt_image_t img) { apt_image_t _img = img; - _img.data = (uint8_t *)malloc(APT_IMG_WIDTH * img.rows); + _img.data = calloc(APT_IMG_WIDTH * img.rows, sizeof(uint8_t)); memcpy(_img.data, img.data, APT_IMG_WIDTH * img.rows); return _img; } static void decode_telemetry(const float *data, size_t rows, size_t offset, float *wedges) { // Calculate row average - float *telemetry_rows = (float *)malloc(rows * sizeof(float)); + float *telemetry_rows = calloc(rows, sizeof(float)); for (size_t y = 0; y < rows; y++) { telemetry_rows[y] = meanf(&data[y*APT_IMG_WIDTH + offset + APT_CH_WIDTH], APT_TELEMETRY_WIDTH); } @@ -59,7 +59,7 @@ static void decode_telemetry(const float *data, size_t rows, size_t offset, floa // Find the least noisy frame (via standard deviation) float best_noise = FLT_MAX; size_t best_frame = 0; - for (size_t y = telemetry_offset; y < rows; y += APT_FRAME_LEN) { + for (size_t y = telemetry_offset; y < rows-APT_FRAME_LEN; y += APT_FRAME_LEN) { float noise = 0.0f; for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { noise += standard_deviation(&telemetry_rows[y + i*APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT); @@ -79,7 +79,7 @@ static void decode_telemetry(const float *data, size_t rows, size_t offset, floa } static float average_spc(apt_image_t *img, size_t offset) { - float *rows = (float *)malloc(img->rows * sizeof(float)); + float *rows = calloc(img->rows, sizeof(float)); float average = 0.0f; for (size_t y = 0; y < img->rows; y++) { float row_average = 0.0f; @@ -170,7 +170,7 @@ static void make_thermal_lut(apt_image_t *img, avhrr_channel_t ch, int satellite const float B = calibration.rad[ch].B; // Compute PRT temperature - float T[4]; + float T[4] = { 0.0f }; for (size_t n = 0; n < 4; n++) { T[n] = quadratic_calc(img->telemetry[1][n + 9] * APT_COUNT_RATIO, calibration.prt[n]); } @@ -201,7 +201,7 @@ int apt_calibrate_thermal(apt_image_t *img, apt_region_t region) { return 1; } - float lut[256]; + float lut[256] = { 0.0f }; make_thermal_lut(img, img->ch[1], img->satellite, lut); for (size_t y = 0; y < img->rows; y++) { From 9bd911d7e2055a1df2ebcb73e2ead10d74527736 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Thu, 26 Jan 2023 21:36:35 +0000 Subject: [PATCH 19/19] Properly prefix all expored functions with aptdec --- CMakeLists.txt | 9 ++++ aptdec-cli/main.c | 87 +++++++++++++++------------------ aptdec-cli/pngio.c | 24 +++++----- aptdec-cli/pngio.h | 10 ++-- libaptdec/calibration.c | 2 +- libaptdec/calibration.h | 2 +- libaptdec/color.c | 12 ++--- libaptdec/dsp.c | 98 +++++++++++++++++++------------------- libaptdec/effects.c | 34 ++++++------- libaptdec/image.c | 95 +++++++++++++++++++----------------- libaptdec/include/aptdec.h | 95 ++++++++++++++++++------------------ 11 files changed, 238 insertions(+), 230 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b59dae..936782e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,11 @@ if(PNG_FOUND AND SNDFILE_LIBRARIES AND SNDFILE_INCLUDE_DIR) target_compile_options(aptdec-cli PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() + if (USE_ADDRESS_SANITIZER) + target_compile_options(aptdec-cli PRIVATE -fsanitize=address) + target_link_options(aptdec-cli PRIVATE -fsanitize=address) + endif() + install(TARGETS aptdec-cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) file(GLOB LUTS luts/*.png) install(FILES ${LUTS} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/aptdec/luts) @@ -75,6 +80,10 @@ else() target_link_libraries(aptdec PRIVATE m) target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers) endif() +if (USE_ADDRESS_SANITIZER) + target_compile_options(aptdec PRIVATE -fsanitize=address) + target_link_options(aptdec PRIVATE -fsanitize=address) +endif() install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/aptdec-cli/main.c b/aptdec-cli/main.c index c9da9e0..de76ce6 100644 --- a/aptdec-cli/main.c +++ b/aptdec-cli/main.c @@ -67,7 +67,6 @@ static int freq_from_filename(const char *filename); static int satid_from_freq(int freq); static size_t callback(float *samples, size_t count, void *context); static void write_line(writer_t *png, float *row); -apt_image_t strip(apt_image_t img); int array_contains(char **array, char *value, size_t n); static volatile int sigint_stop = 0; @@ -183,7 +182,7 @@ static int process_file(const char *path, options_t *opts) { if (opts->realtime) { char filename[269] = { 0 }; sprintf(filename, "%s-decoding.png", name); - realtime_png = writer_init(filename, APT_REGION_FULL, APTDEC_MAX_HEIGHT, PNG_COLOR_TYPE_GRAY, "Unknown"); + realtime_png = writer_init(filename, APTDEC_REGION_FULL, APTDEC_MAX_HEIGHT, PNG_COLOR_TYPE_GRAY, "Unknown"); // Capture Ctrl+C signal(SIGINT, sigint_handler); @@ -209,10 +208,10 @@ static int process_file(const char *path, options_t *opts) { } // Decode image - float *data = calloc(APT_IMG_WIDTH * (APTDEC_MAX_HEIGHT+1), sizeof(float)); + float *data = calloc(APTDEC_IMG_WIDTH * (APTDEC_MAX_HEIGHT+1), sizeof(float)); size_t rows; for (rows = 0; rows < APTDEC_MAX_HEIGHT; rows++) { - float *row = &data[rows * APT_IMG_WIDTH]; + float *row = &data[rows * APTDEC_IMG_WIDTH]; // Break the loop when there are no more samples or the process has been sent SIGINT if (aptdec_getrow(aptdec, row, callback, &audioFile) == 0 || sigint_stop) { @@ -220,7 +219,10 @@ static int process_file(const char *path, options_t *opts) { } if (opts->realtime) { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" write_line(realtime_png, row); +#pragma GCC diagnostic pop } fprintf(stderr, "Row: %zu/%zu\r", rows+1, audioFile.info.frames/audioFile.info.samplerate * 2); @@ -245,7 +247,7 @@ static int process_file(const char *path, options_t *opts) { // Normalize int error; - apt_image_t img = apt_normalize(data, rows, opts->satellite, &error); + aptdec_image_t img = aptdec_normalize(data, rows, opts->satellite, &error); free(data); if (error) { error_noexit("Normalization failed"); @@ -274,13 +276,13 @@ static int process_file(const char *path, options_t *opts) { for (size_t i = 0; i < effects_len; i++) { if (strcmp(effects[i], "crop") == 0) { - apt_crop(&img); + aptdec_crop(&img); } else if (strcmp(effects[i], "denoise") == 0) { - apt_denoise(&img, APT_REGION_CHA); - apt_denoise(&img, APT_REGION_CHB); + aptdec_denoise(&img, APTDEC_REGION_CHA); + aptdec_denoise(&img, APTDEC_REGION_CHB); } else if (strcmp(effects[i], "flip") == 0) { - apt_flip(&img, APT_REGION_CHA); - apt_flip(&img, APT_REGION_CHB); + aptdec_flip(&img, APTDEC_REGION_CHA); + aptdec_flip(&img, APTDEC_REGION_CHB); } } @@ -300,11 +302,11 @@ static int process_file(const char *path, options_t *opts) { sprintf(description, "Calibrated thermal image, channel %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]); // Perform visible calibration - apt_image_t _img = apt_image_clone(img); - apt_calibrate_thermal(&_img, APT_REGION_CHA); + aptdec_image_t _img = aptdec_image_clone(img); + aptdec_calibrate_thermal(&_img, APTDEC_REGION_CHA); - writer_t *writer = writer_init(filename, APT_REGION_CHB, img.rows, PNG_COLOR_TYPE_RGB, description); - writer_write_image_gradient(writer, &_img, temperature_gradient); + writer_t *writer = writer_init(filename, APTDEC_REGION_CHB, img.rows, PNG_COLOR_TYPE_RGB, description); + writer_write_image_gradient(writer, &_img, aptdec_temperature_gradient); writer_free(writer); free(_img.data); @@ -319,10 +321,10 @@ static int process_file(const char *path, options_t *opts) { sprintf(description, "Calibrated visible image, channel %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]); // Perform visible calibration - apt_image_t _img = apt_image_clone(img); - apt_calibrate_visible(&_img, APT_REGION_CHA); + aptdec_image_t _img = aptdec_image_clone(img); + aptdec_calibrate_visible(&_img, APTDEC_REGION_CHA); - writer_t *writer = writer_init(filename, APT_REGION_CHA, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer_t *writer = writer_init(filename, APTDEC_REGION_CHA, img.rows, PNG_COLOR_TYPE_GRAY, description); writer_write_image(writer, &_img); writer_free(writer); @@ -335,11 +337,11 @@ static int process_file(const char *path, options_t *opts) { for (size_t i = 0; i < effects_len; i++) { if (strcmp(effects[i], "stretch") == 0) { - apt_stretch(&img, APT_REGION_CHA); - apt_stretch(&img, APT_REGION_CHB); + aptdec_stretch(&img, APTDEC_REGION_CHA); + aptdec_stretch(&img, APTDEC_REGION_CHB); } else if (strcmp(effects[i], "equalize") == 0) { - apt_equalize(&img, APT_REGION_CHA); - apt_equalize(&img, APT_REGION_CHB); + aptdec_equalize(&img, APTDEC_REGION_CHA); + aptdec_equalize(&img, APTDEC_REGION_CHB); } } @@ -365,12 +367,13 @@ static int process_file(const char *path, options_t *opts) { writer_t *writer; if (array_contains(effects, "strip", effects_len)) { - writer = writer_init(filename, (apt_region_t){0, APT_CH_WIDTH*2}, img.rows, PNG_COLOR_TYPE_GRAY, description); - apt_image_t _img = strip(img); + writer = writer_init(filename, (aptdec_region_t){0, APTDEC_CH_WIDTH*2}, img.rows, PNG_COLOR_TYPE_GRAY, description); + aptdec_image_t _img = aptdec_image_clone(img); + aptdec_strip(&_img); writer_write_image(writer, &_img); free(_img.data); } else { - writer = writer_init(filename, APT_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer = writer_init(filename, APTDEC_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); writer_write_image(writer, &img); } writer_free(writer); @@ -389,7 +392,7 @@ static int process_file(const char *path, options_t *opts) { png_colorp lut = calloc(256*256, sizeof(png_color)); if (read_lut(opts->lut, lut)) { - writer_t *writer = writer_init(filename, APT_REGION_CHA, img.rows, PNG_COLOR_TYPE_RGB, description); + writer_t *writer = writer_init(filename, APTDEC_REGION_CHA, img.rows, PNG_COLOR_TYPE_RGB, description); writer_write_image_lut(writer, &img, lut); writer_free(writer); } @@ -405,12 +408,13 @@ static int process_file(const char *path, options_t *opts) { writer_t *writer; if (array_contains(effects, "strip", effects_len)) { - writer = writer_init(filename, (apt_region_t){0, APT_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description); - apt_image_t _img = strip(img); + writer = writer_init(filename, (aptdec_region_t){0, APTDEC_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description); + aptdec_image_t _img = aptdec_image_clone(img); + aptdec_strip(&_img); writer_write_image(writer, &_img); free(_img.data); } else { - writer = writer_init(filename, APT_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer = writer_init(filename, APTDEC_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); writer_write_image(writer, &img); } writer_free(writer); @@ -422,12 +426,13 @@ static int process_file(const char *path, options_t *opts) { writer_t *writer; if (array_contains(effects, "strip", effects_len)) { - writer = writer_init(filename, (apt_region_t){APT_CH_WIDTH, APT_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description); - apt_image_t _img = strip(img); + writer = writer_init(filename, (aptdec_region_t){APTDEC_CH_WIDTH, APTDEC_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description); + aptdec_image_t _img = aptdec_image_clone(img); + aptdec_strip(&_img); writer_write_image(writer, &_img); free(_img.data); } else { - writer = writer_init(filename, APT_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); + writer = writer_init(filename, APTDEC_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description); writer_write_image(writer, &img); } writer_free(writer); @@ -500,31 +505,17 @@ static size_t callback(float *samples, size_t count, void *context) { static void write_line(writer_t *png, float *row) { float min = FLT_MAX; float max = FLT_MIN; - for (int i = 0; i < APT_IMG_WIDTH; i++) { + for (int i = 0; i < APTDEC_IMG_WIDTH; i++) { if (row[i] < min) min = row[i]; if (row[i] > max) max = row[i]; } - png_byte pixels[APT_IMG_WIDTH]; - for (int i = 0; i < APT_IMG_WIDTH; i++) { + png_byte pixels[APTDEC_IMG_WIDTH]; + for (int i = 0; i < APTDEC_IMG_WIDTH; i++) { pixels[i] = clamp_int(roundf((row[i]-min) / (max-min) * 255.0f), 0, 255); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" png_write_row(png->png, pixels); -#pragma GCC diagnostic pop -} - -apt_image_t strip(apt_image_t img) { - uint8_t *data = calloc(img.rows * APT_IMG_WIDTH, sizeof(uint8_t)); - for (size_t y = 0; y < img.rows; y++) { - memcpy(&data[y*APT_IMG_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHA_OFFSET], APT_CH_WIDTH); - memcpy(&data[y*APT_IMG_WIDTH + APT_CH_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHB_OFFSET], APT_CH_WIDTH); - } - - img.data = data; - return img; } int array_contains(char **array, char *value, size_t n) { diff --git a/aptdec-cli/pngio.c b/aptdec-cli/pngio.c index c60feaf..cf83b2f 100644 --- a/aptdec-cli/pngio.c +++ b/aptdec-cli/pngio.c @@ -24,7 +24,7 @@ #include "util.h" -writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height, int color, char *channel) { +writer_t *writer_init(const char *filename, aptdec_region_t region, uint32_t height, int color, char *channel) { writer_t *png = calloc(1, sizeof(writer_t)); png->region = region; @@ -64,17 +64,17 @@ writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height return png; } -void writer_write_image(writer_t *png, const apt_image_t *img) { +void writer_write_image(writer_t *png, const aptdec_image_t *img) { for (size_t y = 0; y < img->rows; y++) { - png_write_row(png->png, &img->data[y*APT_IMG_WIDTH + png->region.offset]); + png_write_row(png->png, &img->data[y*APTDEC_IMG_WIDTH + png->region.offset]); } } -void writer_write_image_gradient(writer_t *png, const apt_image_t *img, const uint32_t *gradient) { +void writer_write_image_gradient(writer_t *png, const aptdec_image_t *img, const uint32_t *gradient) { for (size_t y = 0; y < img->rows; y++) { - png_color pixels[APT_IMG_WIDTH]; - for (size_t x = 0; x < APT_IMG_WIDTH; x++) { - apt_rgb_t pixel = apt_gradient(gradient, img->data[y*APT_IMG_WIDTH + x + png->region.offset]); + png_color pixels[APTDEC_IMG_WIDTH]; + for (size_t x = 0; x < APTDEC_IMG_WIDTH; x++) { + aptdec_rgb_t pixel = aptdec_gradient(gradient, img->data[y*APTDEC_IMG_WIDTH + x + png->region.offset]); pixels[x] = (png_color){ pixel.r, pixel.g, pixel.b }; } @@ -82,12 +82,12 @@ void writer_write_image_gradient(writer_t *png, const apt_image_t *img, const ui } } -void writer_write_image_lut(writer_t *png, const apt_image_t *img, const png_colorp lut) { +void writer_write_image_lut(writer_t *png, const aptdec_image_t *img, const png_colorp lut) { for (size_t y = 0; y < img->rows; y++) { - png_color pixels[APT_CH_WIDTH]; - for (size_t x = 0; x < APT_CH_WIDTH; x++) { - uint8_t a = img->data[y*APT_IMG_WIDTH + x + APT_CHA_OFFSET]; - uint8_t b = img->data[y*APT_IMG_WIDTH + x + APT_CHB_OFFSET]; + png_color pixels[APTDEC_CH_WIDTH]; + for (size_t x = 0; x < APTDEC_CH_WIDTH; x++) { + uint8_t a = img->data[y*APTDEC_IMG_WIDTH + x + APTDEC_CHA_OFFSET]; + uint8_t b = img->data[y*APTDEC_IMG_WIDTH + x + APTDEC_CHB_OFFSET]; pixels[x] = lut[b*256 + a]; } diff --git a/aptdec-cli/pngio.h b/aptdec-cli/pngio.h index e71d632..c4b2c91 100644 --- a/aptdec-cli/pngio.h +++ b/aptdec-cli/pngio.h @@ -26,15 +26,15 @@ typedef struct { png_structp png; png_infop info; FILE *file; - apt_region_t region; + aptdec_region_t region; } writer_t; -writer_t *writer_init(const char *filename, apt_region_t region, uint32_t height, int color, char *channel); +writer_t *writer_init(const char *filename, aptdec_region_t region, uint32_t height, int color, char *channel); void writer_free(writer_t *png); -void writer_write_image(writer_t *png, const apt_image_t *img); -void writer_write_image_gradient(writer_t *png, const apt_image_t *img, const uint32_t *gradient); -void writer_write_image_lut(writer_t *png, const apt_image_t *img, const png_colorp lut); +void writer_write_image(writer_t *png, const aptdec_image_t *img); +void writer_write_image_gradient(writer_t *png, const aptdec_image_t *img, const uint32_t *gradient); +void writer_write_image_lut(writer_t *png, const aptdec_image_t *img, const png_colorp lut); int read_lut(const char *filename, png_colorp out); diff --git a/libaptdec/calibration.c b/libaptdec/calibration.c index 0bec609..443aedc 100644 --- a/libaptdec/calibration.c +++ b/libaptdec/calibration.c @@ -112,7 +112,7 @@ const calibration_t calibration[3] = { } }; -calibration_t get_calibration(apt_satellite_t satid) { +calibration_t get_calibration(aptdec_satellite_t satid) { switch (satid) { case NOAA15: return calibration[0]; case NOAA18: return calibration[1]; diff --git a/libaptdec/calibration.h b/libaptdec/calibration.h index 46313e2..1050241 100644 --- a/libaptdec/calibration.h +++ b/libaptdec/calibration.h @@ -52,6 +52,6 @@ static const float C1 = 1.1910427e-5f; // Second radiation constant (cm-K) static const float C2 = 1.4387752f; -calibration_t get_calibration(apt_satellite_t satid); +calibration_t get_calibration(aptdec_satellite_t satid); #endif diff --git a/libaptdec/color.c b/libaptdec/color.c index 43bacb2..befd854 100644 --- a/libaptdec/color.c +++ b/libaptdec/color.c @@ -23,16 +23,16 @@ // clang-format off -apt_rgb_t apt_gradient(const uint32_t *gradient, uint8_t val) { - return (apt_rgb_t) { +aptdec_rgb_t aptdec_gradient(const uint32_t *gradient, uint8_t val) { + return (aptdec_rgb_t) { (gradient[val] & 0x00FF0000) >> 16, (gradient[val] & 0x0000FF00) >> 8, (gradient[val] & 0x000000FF) }; } -apt_rgb_t apt_composite_rgb(apt_rgb_t top, float top_alpha, apt_rgb_t bottom, float bottom_alpha) { - return (apt_rgb_t) { +aptdec_rgb_t aptdec_composite_rgb(aptdec_rgb_t top, float top_alpha, aptdec_rgb_t bottom, float bottom_alpha) { + return (aptdec_rgb_t) { MCOMPOSITE(top.r, top_alpha, bottom.r, bottom_alpha), MCOMPOSITE(top.g, top_alpha, bottom.g, bottom_alpha), MCOMPOSITE(top.b, top_alpha, bottom.b, bottom_alpha) @@ -40,7 +40,7 @@ apt_rgb_t apt_composite_rgb(apt_rgb_t top, float top_alpha, apt_rgb_t bottom, fl } // Taken from WXtoImg -const uint32_t temperature_gradient[256] = { +const uint32_t aptdec_temperature_gradient[256] = { 0x45008F, 0x460091, 0x470092, 0x480094, 0x490096, 0x4A0098, 0x4B009B, 0x4D009D, 0x4E00A0, 0x5000A2, 0x5100A5, 0x5200A7, 0x5400AA, 0x5600AE, 0x5700B1, 0x5800B4, 0x5A00B7, 0x5C00BA, 0x5E00BD, 0x5F00C0, 0x6100C4, @@ -81,7 +81,7 @@ const uint32_t temperature_gradient[256] = { }; // Taken from WXtoImg -const uint32_t precipitation_gradient[58] = { +const uint32_t aptdec_precipitation_gradient[58] = { 0x088941, 0x00C544, 0x00D12C, 0x00E31C, 0x00F906, 0x14FF00, 0x3EFF00, 0x5DFF00, 0x80FF00, 0xABFF00, 0xCDFE00, 0xF8FF00, 0xFFE600, 0xFFB800, 0xFF9800, 0xFF7500, 0xFF4900, 0xFE2600, 0xFF0400, 0xDF0000, 0xA80000, diff --git a/libaptdec/dsp.c b/libaptdec/dsp.c index c82a412..d0eef34 100644 --- a/libaptdec/dsp.c +++ b/libaptdec/dsp.c @@ -54,7 +54,7 @@ typedef struct { size_t ntaps; } fir_t; -struct aptdec_t { +struct aptdec { float sample_rate; float sync_frequency; @@ -62,7 +62,7 @@ struct aptdec_t { fir_t *hilbert; float low_pass[LOW_PASS_SIZE]; - float row_buffer[APT_IMG_WIDTH + SYNC_SIZE + 2]; + float row_buffer[APTDEC_IMG_WIDTH + SYNC_SIZE + 2]; float interpolator_buffer[APTDEC_BUFFER_SIZE]; size_t interpolator_n; @@ -100,15 +100,15 @@ pll_t *pll_init(float alpha, float beta, float min_freq, float max_freq, float s } aptdec_t *aptdec_init(float sample_rate) { - if (sample_rate > 96000 || sample_rate < (CARRIER_FREQ + APT_IMG_WIDTH) * 2.0f) { + if (sample_rate > 96000 || sample_rate < (CARRIER_FREQ + APTDEC_IMG_WIDTH) * 2.0f) { return NULL; } - aptdec_t *apt = calloc(1, sizeof(aptdec_t)); - apt->sample_rate = sample_rate; - apt->sync_frequency = 1.0f; - apt->interpolator_n = APTDEC_BUFFER_SIZE; - apt->interpolator_offset = 0.0f; + aptdec_t *aptdec = calloc(1, sizeof(aptdec_t)); + aptdec->sample_rate = sample_rate; + aptdec->sync_frequency = 1.0f; + aptdec->interpolator_n = APTDEC_BUFFER_SIZE; + aptdec->interpolator_offset = 0.0f; // PLL configuration // https://www.trondeau.com/blog/2011/8/13/control-loop-gain-values.html @@ -116,30 +116,30 @@ aptdec_t *aptdec_init(float sample_rate) { float bw = 0.005f; float alpha = (4.0f * damp * bw) / (1.0f + 2.0f * damp * bw + bw * bw); float beta = (4.0f * bw * bw) / (1.0f + 2.0f * damp * bw + bw * bw); - apt->pll = pll_init(alpha, beta, CARRIER_FREQ-MAX_CARRIER_OFFSET, CARRIER_FREQ+MAX_CARRIER_OFFSET, sample_rate); - if (apt->pll == NULL) { - free(apt); + aptdec->pll = pll_init(alpha, beta, CARRIER_FREQ-MAX_CARRIER_OFFSET, CARRIER_FREQ+MAX_CARRIER_OFFSET, sample_rate); + if (aptdec->pll == NULL) { + free(aptdec); return NULL; } // Hilbert transform - apt->hilbert = fir_init(APTDEC_BUFFER_SIZE, 31); - if (apt->hilbert == NULL) { - free(apt->pll); - free(apt); + aptdec->hilbert = fir_init(APTDEC_BUFFER_SIZE, 31); + if (aptdec->hilbert == NULL) { + free(aptdec->pll); + free(aptdec); return NULL; } - design_hilbert(apt->hilbert->taps, apt->hilbert->ntaps); + design_hilbert(aptdec->hilbert->taps, aptdec->hilbert->ntaps); - design_low_pass(apt->low_pass, apt->sample_rate, (2080.0f + CARRIER_FREQ) / 2.0f, LOW_PASS_SIZE); + design_low_pass(aptdec->low_pass, aptdec->sample_rate, (2080.0f + CARRIER_FREQ) / 2.0f, LOW_PASS_SIZE); - return apt; + return aptdec; } -void aptdec_free(aptdec_t *apt) { - fir_free(apt->hilbert); - free(apt->pll); - free(apt); +void aptdec_free(aptdec_t *aptdec) { + fir_free(aptdec->hilbert); + free(aptdec->pll); + free(aptdec); } static complexf_t pll_work(pll_t *pll, complexf_t in) { @@ -159,52 +159,52 @@ static complexf_t pll_work(pll_t *pll, complexf_t in) { return in; } -static int am_demod(aptdec_t *apt, float *out, size_t count, aptdec_callback_t callback, void *context) { - size_t read = callback(&apt->hilbert->ring_buffer[apt->hilbert->ntaps], count, context); +static int am_demod(aptdec_t *aptdec, float *out, size_t count, aptdec_callback_t callback, void *context) { + size_t read = callback(&aptdec->hilbert->ring_buffer[aptdec->hilbert->ntaps], count, context); for (size_t i = 0; i < read; i++) { - complexf_t sample = hilbert_transform(&apt->hilbert->ring_buffer[i], apt->hilbert->taps, apt->hilbert->ntaps); - out[i] = crealf(pll_work(apt->pll, sample)); + complexf_t sample = hilbert_transform(&aptdec->hilbert->ring_buffer[i], aptdec->hilbert->taps, aptdec->hilbert->ntaps); + out[i] = crealf(pll_work(aptdec->pll, sample)); } - memcpy(apt->hilbert->ring_buffer, &apt->hilbert->ring_buffer[read], apt->hilbert->ntaps*sizeof(float)); + memcpy(aptdec->hilbert->ring_buffer, &aptdec->hilbert->ring_buffer[read], aptdec->hilbert->ntaps*sizeof(float)); return read; } -static int get_pixels(aptdec_t *apt, float *out, size_t count, aptdec_callback_t callback, void *context) { - float ratio = apt->sample_rate / (4160.0f * apt->sync_frequency); +static int get_pixels(aptdec_t *aptdec, float *out, size_t count, aptdec_callback_t callback, void *context) { + float ratio = aptdec->sample_rate / (4160.0f * aptdec->sync_frequency); for (size_t i = 0; i < count; i++) { // Get more samples if there are less than `LOW_PASS_SIZE` available - if (apt->interpolator_n + LOW_PASS_SIZE > APTDEC_BUFFER_SIZE) { - memcpy(apt->interpolator_buffer, &apt->interpolator_buffer[apt->interpolator_n], (APTDEC_BUFFER_SIZE-apt->interpolator_n) * sizeof(float)); + if (aptdec->interpolator_n + LOW_PASS_SIZE > APTDEC_BUFFER_SIZE) { + memcpy(aptdec->interpolator_buffer, &aptdec->interpolator_buffer[aptdec->interpolator_n], (APTDEC_BUFFER_SIZE-aptdec->interpolator_n) * sizeof(float)); - size_t read = am_demod(apt, &apt->interpolator_buffer[APTDEC_BUFFER_SIZE-apt->interpolator_n], apt->interpolator_n, callback, context); - if (read != apt->interpolator_n) { + size_t read = am_demod(aptdec, &aptdec->interpolator_buffer[APTDEC_BUFFER_SIZE-aptdec->interpolator_n], aptdec->interpolator_n, callback, context); + if (read != aptdec->interpolator_n) { return i; } - apt->interpolator_n = 0; + aptdec->interpolator_n = 0; } - out[i] = interpolating_convolve(&apt->interpolator_buffer[apt->interpolator_n], apt->low_pass, LOW_PASS_SIZE, apt->interpolator_offset); + out[i] = interpolating_convolve(&aptdec->interpolator_buffer[aptdec->interpolator_n], aptdec->low_pass, LOW_PASS_SIZE, aptdec->interpolator_offset); // Do not question the sacred code - int shift = ceilf(ratio - apt->interpolator_offset); - apt->interpolator_offset = shift + apt->interpolator_offset - ratio; - apt->interpolator_n += shift; + int shift = ceilf(ratio - aptdec->interpolator_offset); + aptdec->interpolator_offset = shift + aptdec->interpolator_offset - ratio; + aptdec->interpolator_n += shift; } return count; } // Get an entire row of pixels, aligned with sync markers -int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *context) { +int aptdec_getrow(aptdec_t *aptdec, float *row, aptdec_callback_t callback, void *context) { // Wrap the circular buffer - memcpy(apt->row_buffer, &apt->row_buffer[APT_IMG_WIDTH], (SYNC_SIZE + 2) * sizeof(float)); + memcpy(aptdec->row_buffer, &aptdec->row_buffer[APTDEC_IMG_WIDTH], (SYNC_SIZE + 2) * sizeof(float)); - // Get a lines worth (APT_IMG_WIDTH) of samples - if (get_pixels(apt, &apt->row_buffer[SYNC_SIZE + 2], APT_IMG_WIDTH, callback, context) != APT_IMG_WIDTH) { + // Get a lines worth (APTDEC_IMG_WIDTH) of samples + if (get_pixels(aptdec, &aptdec->row_buffer[SYNC_SIZE + 2], APTDEC_IMG_WIDTH, callback, context) != APTDEC_IMG_WIDTH) { return 0; } @@ -214,10 +214,10 @@ int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *c float right = FLT_MIN; size_t phase = 0; - for (size_t i = 0; i < APT_IMG_WIDTH; i++) { - float _left = convolve(&apt->row_buffer[i + 0], sync_pattern, SYNC_SIZE); - float _middle = convolve(&apt->row_buffer[i + 1], sync_pattern, SYNC_SIZE); - float _right = convolve(&apt->row_buffer[i + 2], sync_pattern, SYNC_SIZE); + for (size_t i = 0; i < APTDEC_IMG_WIDTH; i++) { + float _left = convolve(&aptdec->row_buffer[i + 0], sync_pattern, SYNC_SIZE); + float _middle = convolve(&aptdec->row_buffer[i + 1], sync_pattern, SYNC_SIZE); + float _right = convolve(&aptdec->row_buffer[i + 2], sync_pattern, SYNC_SIZE); if (_middle > middle) { left = _left; middle = _middle; @@ -228,11 +228,11 @@ int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *c // Frequency float bias = (left / middle) - (right / middle); - apt->sync_frequency = 1.0f + bias / APT_IMG_WIDTH / 4.0f; + aptdec->sync_frequency = 1.0f + bias / APTDEC_IMG_WIDTH / 4.0f; // Phase - memcpy(&row[APT_IMG_WIDTH], &apt->row_buffer[phase], (APT_IMG_WIDTH - phase) * sizeof(float)); - memcpy(&row[APT_IMG_WIDTH - phase], apt->row_buffer, phase * sizeof(float)); + memcpy(&row[APTDEC_IMG_WIDTH], &aptdec->row_buffer[phase], (APTDEC_IMG_WIDTH - phase) * sizeof(float)); + memcpy(&row[APTDEC_IMG_WIDTH - phase], aptdec->row_buffer, phase * sizeof(float)); return 1; } diff --git a/libaptdec/effects.c b/libaptdec/effects.c index 1afec32..37b875d 100644 --- a/libaptdec/effects.c +++ b/libaptdec/effects.c @@ -26,12 +26,12 @@ #include "util.h" #include "filter.h" -void apt_equalize(apt_image_t *img, apt_region_t region) { +void aptdec_equalize(aptdec_image_t *img, aptdec_region_t region) { // Plot histogram size_t histogram[256] = {0}; for (size_t y = 0; y < img->rows; y++) { for (size_t x = 0; x < region.width; x++) { - histogram[img->data[y * APT_IMG_WIDTH + x + region.offset]]++; + histogram[img->data[y * APTDEC_IMG_WIDTH + x + region.offset]]++; } } @@ -46,8 +46,8 @@ void apt_equalize(apt_image_t *img, apt_region_t region) { int area = img->rows * region.width; for (size_t y = 0; y < img->rows; y++) { for (size_t x = 0; x < region.width; x++) { - int k = (int)img->data[y * APT_IMG_WIDTH + x + region.offset]; - img->data[y * APT_IMG_WIDTH + x + region.offset] = (255.0f / area) * cf[k]; + int k = (int)img->data[y * APTDEC_IMG_WIDTH + x + region.offset]; + img->data[y * APTDEC_IMG_WIDTH + x + region.offset] = (255.0f / area) * cf[k]; } } } @@ -56,18 +56,18 @@ void apt_equalize(apt_image_t *img, apt_region_t region) { static void image_apply_linear(uint8_t *data, int rows, int offset, int width, linear_t regr) { for (int y = 0; y < rows; y++) { for (int x = 0; x < width; x++) { - float pv = linear_calc(data[y * APT_IMG_WIDTH + x + offset], regr); - data[y * APT_IMG_WIDTH + x + offset] = clamp_int(roundf(pv), 0, 255); + float pv = linear_calc(data[y * APTDEC_IMG_WIDTH + x + offset], regr); + data[y * APTDEC_IMG_WIDTH + x + offset] = clamp_int(roundf(pv), 0, 255); } } } -void apt_stretch(apt_image_t *img, apt_region_t region) { +void aptdec_stretch(aptdec_image_t *img, aptdec_region_t region) { // Plot histogram size_t histogram[256] = { 0 }; for (size_t y = 0; y < img->rows; y++) { for (size_t x = 0; x < region.width; x++) { - histogram[img->data[y*APT_IMG_WIDTH + x + region.offset]]++; + histogram[img->data[y*APTDEC_IMG_WIDTH + x + region.offset]]++; } } @@ -99,32 +99,32 @@ void apt_stretch(apt_image_t *img, apt_region_t region) { // Median denoise (with deviation threshold) -void apt_denoise(apt_image_t *img, apt_region_t region) { +void aptdec_denoise(aptdec_image_t *img, aptdec_region_t region) { for (size_t y = 1; y < img->rows - 1; y++) { for (size_t x = 1; x < region.width - 1; x++) { float pixels[9] = { 0.0f }; int pixeln = 0; for (int y2 = -1; y2 < 2; y2++) { for (int x2 = -1; x2 < 2; x2++) { - pixels[pixeln++] = img->data[(y + y2) * APT_IMG_WIDTH + (x + region.offset) + x2]; + pixels[pixeln++] = img->data[(y + y2) * APTDEC_IMG_WIDTH + (x + region.offset) + x2]; } } if (standard_deviation(pixels, 9) > 15) { - img->data[y * APT_IMG_WIDTH + x + region.offset] = medianf(pixels, 9); + img->data[y * APTDEC_IMG_WIDTH + x + region.offset] = medianf(pixels, 9); } } } } // Flips a channel, for northbound passes -void apt_flip(apt_image_t *img, apt_region_t region) { +void aptdec_flip(aptdec_image_t *img, aptdec_region_t region) { for (size_t y = 1; y < img->rows; y++) { for (int x = 1; x < ceil(region.width / 2.0f); x++) { // Flip top-left & bottom-right swap_uint8( - &img->data[(img->rows - y) * APT_IMG_WIDTH + region.offset + x], - &img->data[y * APT_IMG_WIDTH + region.offset + (region.width - x)] + &img->data[(img->rows - y) * APTDEC_IMG_WIDTH + region.offset + x], + &img->data[y * APTDEC_IMG_WIDTH + region.offset + (region.width - x)] ); } } @@ -135,7 +135,7 @@ void apt_flip(apt_image_t *img, apt_region_t region) { #include "filter.h" -int apt_crop(apt_image_t *img) { +int aptdec_crop(aptdec_image_t *img) { const float sync_pattern[] = {-1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0}; @@ -146,7 +146,7 @@ int apt_crop(apt_image_t *img) { for (size_t y = 0; y < img->rows; y++) { float temp[39] = { 0.0f }; for (size_t i = 0; i < 39; i++) { - temp[i] = img->data[y * APT_IMG_WIDTH + i]; + temp[i] = img->data[y * APTDEC_IMG_WIDTH + i]; } spc_rows[y] = convolve(temp, &sync_pattern[0], 39); @@ -170,7 +170,7 @@ int apt_crop(apt_image_t *img) { img->rows = (endCrop - startCrop); // Remove the noisy rows at start - memmove(img->data, &img->data[startCrop * APT_IMG_WIDTH], img->rows * APT_IMG_WIDTH * sizeof(float)); + memmove(img->data, &img->data[startCrop * APTDEC_IMG_WIDTH], img->rows * APTDEC_IMG_WIDTH * sizeof(float)); free(spc_rows); return startCrop; diff --git a/libaptdec/image.c b/libaptdec/image.c index e6498bd..b3a878d 100644 --- a/libaptdec/image.c +++ b/libaptdec/image.c @@ -27,12 +27,12 @@ #include "util.h" #include "calibration.h" -#define APT_COUNT_RATIO (1023.0f/255.0f) +#define APTDEC_COUNT_RATIO (1023.0f/255.0f) -apt_image_t apt_image_clone(apt_image_t img) { - apt_image_t _img = img; - _img.data = calloc(APT_IMG_WIDTH * img.rows, sizeof(uint8_t)); - memcpy(_img.data, img.data, APT_IMG_WIDTH * img.rows); +aptdec_image_t aptdec_image_clone(aptdec_image_t img) { + aptdec_image_t _img = img; + _img.data = calloc(APTDEC_IMG_WIDTH * img.rows, sizeof(uint8_t)); + memcpy(_img.data, img.data, APTDEC_IMG_WIDTH * img.rows); return _img; } @@ -40,29 +40,29 @@ static void decode_telemetry(const float *data, size_t rows, size_t offset, floa // Calculate row average float *telemetry_rows = calloc(rows, sizeof(float)); for (size_t y = 0; y < rows; y++) { - telemetry_rows[y] = meanf(&data[y*APT_IMG_WIDTH + offset + APT_CH_WIDTH], APT_TELEMETRY_WIDTH); + telemetry_rows[y] = meanf(&data[y*APTDEC_IMG_WIDTH + offset + APTDEC_CH_WIDTH], APTDEC_TELEMETRY_WIDTH); } // Calculate relative telemetry offset (via step detection, i.e. wedge 8 to 9) size_t telemetry_offset = 0; float max_difference = 0.0f; - for (size_t y = APT_WEDGE_HEIGHT; y <= rows - APT_WEDGE_HEIGHT; y++) { - float difference = sumf(&telemetry_rows[y - APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT) - sumf(&telemetry_rows[y], APT_WEDGE_HEIGHT); + for (size_t y = APTDEC_WEDGE_HEIGHT; y <= rows - APTDEC_WEDGE_HEIGHT; y++) { + float difference = sumf(&telemetry_rows[y - APTDEC_WEDGE_HEIGHT], APTDEC_WEDGE_HEIGHT) - sumf(&telemetry_rows[y], APTDEC_WEDGE_HEIGHT); // Find the maximum difference if (difference > max_difference) { max_difference = difference; - telemetry_offset = (y + 64) % APT_FRAME_LEN; + telemetry_offset = (y + 64) % APTDEC_FRAME_LEN; } } // Find the least noisy frame (via standard deviation) float best_noise = FLT_MAX; size_t best_frame = 0; - for (size_t y = telemetry_offset; y < rows-APT_FRAME_LEN; y += APT_FRAME_LEN) { + for (size_t y = telemetry_offset; y < rows-APTDEC_FRAME_LEN; y += APTDEC_FRAME_LEN) { float noise = 0.0f; - for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { - noise += standard_deviation(&telemetry_rows[y + i*APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT); + for (size_t i = 0; i < APTDEC_FRAME_WEDGES; i++) { + noise += standard_deviation(&telemetry_rows[y + i*APTDEC_WEDGE_HEIGHT], APTDEC_WEDGE_HEIGHT); } if (noise < best_noise) { @@ -71,22 +71,22 @@ static void decode_telemetry(const float *data, size_t rows, size_t offset, floa } } - for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { - wedges[i] = meanf(&telemetry_rows[best_frame + i*APT_WEDGE_HEIGHT], APT_WEDGE_HEIGHT); + for (size_t i = 0; i < APTDEC_FRAME_WEDGES; i++) { + wedges[i] = meanf(&telemetry_rows[best_frame + i*APTDEC_WEDGE_HEIGHT], APTDEC_WEDGE_HEIGHT); } free(telemetry_rows); } -static float average_spc(apt_image_t *img, size_t offset) { +static float average_spc(aptdec_image_t *img, size_t offset) { float *rows = calloc(img->rows, sizeof(float)); float average = 0.0f; for (size_t y = 0; y < img->rows; y++) { float row_average = 0.0f; - for (size_t x = 0; x < APT_SPC_WIDTH; x++) { - row_average += img->data[y*APT_IMG_WIDTH + offset - APT_SPC_WIDTH + x]; + for (size_t x = 0; x < APTDEC_SPC_WIDTH; x++) { + row_average += img->data[y*APTDEC_IMG_WIDTH + offset - APTDEC_SPC_WIDTH + x]; } - row_average /= (float)APT_SPC_WIDTH; + row_average /= (float)APTDEC_SPC_WIDTH; rows[y] = row_average; average += row_average; @@ -106,8 +106,8 @@ static float average_spc(apt_image_t *img, size_t offset) { return weighted_average / (float)n; } -apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satellite, int *error) { - apt_image_t img; +aptdec_image_t aptdec_normalize(const float *data, size_t rows, aptdec_satellite_t satellite, int *error) { + aptdec_image_t img; img.rows = rows; img.satellite = satellite; @@ -118,12 +118,12 @@ apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satell } // Decode and average wedges - float wedges[APT_FRAME_WEDGES]; - float wedges_cha[APT_FRAME_WEDGES]; - float wedges_chb[APT_FRAME_WEDGES]; - decode_telemetry(data, rows, APT_CHA_OFFSET, wedges_cha); - decode_telemetry(data, rows, APT_CHB_OFFSET, wedges_chb); - for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { + float wedges[APTDEC_FRAME_WEDGES]; + float wedges_cha[APTDEC_FRAME_WEDGES]; + float wedges_chb[APTDEC_FRAME_WEDGES]; + decode_telemetry(data, rows, APTDEC_CHA_OFFSET, wedges_cha); + decode_telemetry(data, rows, APTDEC_CHB_OFFSET, wedges_chb); + for (size_t i = 0; i < APTDEC_FRAME_WEDGES; i++) { wedges[i] = (wedges_cha[i] + wedges_chb[i]) / 2.0f; } @@ -136,7 +136,7 @@ apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satell } // Normalize telemetry - for (size_t i = 0; i < APT_FRAME_WEDGES; i++) { + for (size_t i = 0; i < APTDEC_FRAME_WEDGES; i++) { img.telemetry[0][i] = linear_calc(wedges_cha[i], normalization); img.telemetry[1][i] = linear_calc(wedges_chb[i], normalization); } @@ -148,20 +148,20 @@ apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satell if (img.ch[1] < 1 || img.ch[1] > 6) img.ch[1] = AVHRR_CHANNEL_UNKNOWN; // Normalize and quantize image data - img.data = (uint8_t *)malloc(rows * APT_IMG_WIDTH); - for (size_t i = 0; i < rows * APT_IMG_WIDTH; i++) { + img.data = (uint8_t *)malloc(rows * APTDEC_IMG_WIDTH); + for (size_t i = 0; i < rows * APTDEC_IMG_WIDTH; i++) { float count = linear_calc(data[i], normalization); img.data[i] = clamp_int(roundf(count), 0, 255); } // Get space brightness - img.space_view[0] = average_spc(&img, APT_CHA_OFFSET); - img.space_view[1] = average_spc(&img, APT_CHB_OFFSET); + img.space_view[0] = average_spc(&img, APTDEC_CHA_OFFSET); + img.space_view[1] = average_spc(&img, APTDEC_CHB_OFFSET); return img; } -static void make_thermal_lut(apt_image_t *img, avhrr_channel_t ch, int satellite, float *lut) { +static void make_thermal_lut(aptdec_image_t *img, avhrr_channel_t ch, int satellite, float *lut) { ch -= 4; const calibration_t calibration = get_calibration(satellite); const float Ns = calibration.cor[ch].Ns; @@ -172,7 +172,7 @@ static void make_thermal_lut(apt_image_t *img, avhrr_channel_t ch, int satellite // Compute PRT temperature float T[4] = { 0.0f }; for (size_t n = 0; n < 4; n++) { - T[n] = quadratic_calc(img->telemetry[1][n + 9] * APT_COUNT_RATIO, calibration.prt[n]); + T[n] = quadratic_calc(img->telemetry[1][n + 9] * APTDEC_COUNT_RATIO, calibration.prt[n]); } float Tbb = meanf(T, 4); // Blackbody temperature @@ -180,11 +180,11 @@ static void make_thermal_lut(apt_image_t *img, avhrr_channel_t ch, int satellite float Nbb = C1 * pow(Vc, 3) / (expf(C2 * Vc / Tbbstar) - 1.0f); // Blackbody radiance - float Cs = img->space_view[1] * APT_COUNT_RATIO; - float Cb = img->telemetry[1][14] * APT_COUNT_RATIO; + float Cs = img->space_view[1] * APTDEC_COUNT_RATIO; + float Cb = img->telemetry[1][14] * APTDEC_COUNT_RATIO; for (size_t i = 0; i < 256; i++) { - float Nl = Ns + (Nbb - Ns) * (Cs - i * APT_COUNT_RATIO) / (Cs - Cb); // Linear radiance estimate + float Nl = Ns + (Nbb - Ns) * (Cs - i * APTDEC_COUNT_RATIO) / (Cs - Cb); // Linear radiance estimate float Nc = quadratic_calc(Nl, calibration.cor[ch].quadratic); // Non-linear correction float Ne = Nl + Nc; // Corrected radiance @@ -196,7 +196,7 @@ static void make_thermal_lut(apt_image_t *img, avhrr_channel_t ch, int satellite } } -int apt_calibrate_thermal(apt_image_t *img, apt_region_t region) { +int aptdec_calibrate_thermal(aptdec_image_t *img, aptdec_region_t region) { if (img->ch[1] != AVHRR_CHANNEL_4 && img->ch[1] != AVHRR_CHANNEL_5 && img->ch[1] != AVHRR_CHANNEL_3B) { return 1; } @@ -206,8 +206,8 @@ int apt_calibrate_thermal(apt_image_t *img, apt_region_t region) { for (size_t y = 0; y < img->rows; y++) { for (size_t x = 0; x < region.width; x++) { - float temperature = lut[img->data[y * APT_IMG_WIDTH + region.offset + x]]; - img->data[y * APT_IMG_WIDTH + region.offset + x] = clamp_int(roundf((temperature + 100.0) / 160.0 * 255.0), 0, 255); + float temperature = lut[img->data[y * APTDEC_IMG_WIDTH + region.offset + x]]; + img->data[y * APTDEC_IMG_WIDTH + region.offset + x] = clamp_int(roundf((temperature + 100.0) / 160.0 * 255.0), 0, 255); } } @@ -216,13 +216,13 @@ int apt_calibrate_thermal(apt_image_t *img, apt_region_t region) { static float calibrate_pixel_visible(float value, int channel, calibration_t cal) { if (value > cal.visible[channel].cutoff) { - return linear_calc(value * APT_COUNT_RATIO, cal.visible[channel].high) / 100.0f * 255.0f; + return linear_calc(value * APTDEC_COUNT_RATIO, cal.visible[channel].high) / 100.0f * 255.0f; } else { - return linear_calc(value * APT_COUNT_RATIO, cal.visible[channel].low) / 100.0f * 255.0f; + return linear_calc(value * APTDEC_COUNT_RATIO, cal.visible[channel].low) / 100.0f * 255.0f; } } -int apt_calibrate_visible(apt_image_t *img, apt_region_t region) { +int aptdec_calibrate_visible(aptdec_image_t *img, aptdec_region_t region) { if (img->ch[0] != AVHRR_CHANNEL_1 && img->ch[0] != AVHRR_CHANNEL_2) { return 1; } @@ -230,10 +230,17 @@ int apt_calibrate_visible(apt_image_t *img, apt_region_t region) { calibration_t calibration = get_calibration(img->satellite); for (size_t y = 0; y < img->rows; y++) { for (size_t x = 0; x < region.width; x++) { - float albedo = calibrate_pixel_visible(img->data[y * APT_IMG_WIDTH + region.offset + x], img->ch[0]-1, calibration); - img->data[y * APT_IMG_WIDTH + region.offset + x] = clamp_int(roundf(albedo), 0, 255); + float albedo = calibrate_pixel_visible(img->data[y * APTDEC_IMG_WIDTH + region.offset + x], img->ch[0]-1, calibration); + img->data[y * APTDEC_IMG_WIDTH + region.offset + x] = clamp_int(roundf(albedo), 0, 255); } } return 0; } + +void aptdec_strip(aptdec_image_t* img) { + for (size_t y = 0; y < img->rows; y++) { + memcpy(&img->data[y*APTDEC_IMG_WIDTH], &img->data[y*APTDEC_IMG_WIDTH + APTDEC_CHA_OFFSET], APTDEC_CH_WIDTH); + memcpy(&img->data[y*APTDEC_IMG_WIDTH + APTDEC_CH_WIDTH], &img->data[y*APTDEC_IMG_WIDTH + APTDEC_CHB_OFFSET], APTDEC_CH_WIDTH); + } +} diff --git a/libaptdec/include/aptdec.h b/libaptdec/include/aptdec.h index 9d3cc5b..a730c5e 100644 --- a/libaptdec/include/aptdec.h +++ b/libaptdec/include/aptdec.h @@ -40,30 +40,30 @@ extern "C" { #endif // Height of a single telemetry wedge -#define APT_WEDGE_HEIGHT 8 +#define APTDEC_WEDGE_HEIGHT 8 // Numbers of wedges in a frame -#define APT_FRAME_WEDGES 16 +#define APTDEC_FRAME_WEDGES 16 // Height of a telemetry frame -#define APT_FRAME_LEN (APT_WEDGE_HEIGHT * APT_FRAME_WEDGES) +#define APTDEC_FRAME_LEN (APTDEC_WEDGE_HEIGHT * APTDEC_FRAME_WEDGES) // Width of the overall image -#define APT_IMG_WIDTH 2080 +#define APTDEC_IMG_WIDTH 2080 // Width of sync marker -#define APT_SYNC_WIDTH 39 +#define APTDEC_SYNC_WIDTH 39 // Width of space view -#define APT_SPC_WIDTH 47 +#define APTDEC_SPC_WIDTH 47 // Width of telemetry -#define APT_TELEMETRY_WIDTH 45 +#define APTDEC_TELEMETRY_WIDTH 45 // Width of a single video channel -#define APT_CH_WIDTH 909 +#define APTDEC_CH_WIDTH 909 // Offset to channel A video data -#define APT_CHA_OFFSET (APT_SYNC_WIDTH + APT_SPC_WIDTH) +#define APTDEC_CHA_OFFSET (APTDEC_SYNC_WIDTH + APTDEC_SPC_WIDTH) // Offset to channel B video data -#define APT_CHB_OFFSET (APT_SYNC_WIDTH + APT_SPC_WIDTH + APT_CH_WIDTH + APT_TELEMETRY_WIDTH + APT_SYNC_WIDTH + APT_SPC_WIDTH) +#define APTDEC_CHB_OFFSET (APTDEC_SYNC_WIDTH + APTDEC_SPC_WIDTH + APTDEC_CH_WIDTH + APTDEC_TELEMETRY_WIDTH + APTDEC_SYNC_WIDTH + APTDEC_SPC_WIDTH) -// Number of rows needed for apt_normalize to (reliably) work -#define APTDEC_NORMALIZE_ROWS (APT_FRAME_LEN * 2) +// Number of rows needed for aptdec_normalize to (reliably) work +#define APTDEC_NORMALIZE_ROWS (APTDEC_FRAME_LEN * 2) // Maximum amount of samples that will be requested from aptdec_callback_t #define APTDEC_BUFFER_SIZE 16384 @@ -73,7 +73,7 @@ extern "C" { // Channel 3B: mid-infrared (3.55-3.93 um) // Channel 4: thermal-infrared (10.3-11.3 um) // Channel 5: thermal-infrared (11.5-12.5 um) -typedef enum apt_channel { +typedef enum aptdec_channel { AVHRR_CHANNEL_UNKNOWN, AVHRR_CHANNEL_1, AVHRR_CHANNEL_2, @@ -83,41 +83,41 @@ typedef enum apt_channel { AVHRR_CHANNEL_3B } avhrr_channel_t; -typedef enum apt_satellite { +typedef enum aptdec_satellite { NOAA15, NOAA18, NOAA19 -} apt_satellite_t; +} aptdec_satellite_t; -typedef struct { +typedef struct aptdec_image { uint8_t *data; // Image data size_t rows; // Number of rows // Telemetry - apt_satellite_t satellite; + aptdec_satellite_t satellite; avhrr_channel_t ch[2]; float space_view[2]; float telemetry[2][16]; -} apt_image_t; +} aptdec_image_t; -typedef struct { +typedef struct aptdec_rgb { uint8_t r, g, b; -} apt_rgb_t; +} aptdec_rgb_t; -typedef struct { +typedef struct aptdec_region { size_t offset; size_t width; -} apt_region_t; +} aptdec_region_t; -typedef struct aptdec_t aptdec_t; +typedef struct aptdec aptdec_t; // Callback function to get samples // `context` is the same as passed to aptdec_getrow typedef size_t (*aptdec_callback_t)(float *samples, size_t count, void *context); -// Clone an apt_image_t struct +// Clone an aptdec_image_t struct // Useful for calibration -APTDEC_API apt_image_t apt_image_clone(apt_image_t img); +APTDEC_API aptdec_image_t aptdec_image_clone(aptdec_image_t img); // Returns version of libaptdec in git tag format // i.e. v2.0.0 or v2.0.0-1-xxxxxx @@ -126,43 +126,44 @@ APTDEC_API char *aptdec_get_version(void); // Create and destroy libaptdec instances // If aptdec_init fails it will return NULL APTDEC_API aptdec_t *aptdec_init(float sample_rate); -APTDEC_API void aptdec_free(aptdec_t *apt); +APTDEC_API void aptdec_free(aptdec_t *aptdec); // Normalize and quantize raw image data -// Data is arranged so that each row starts at APT_IMG_WIDTH*y -APTDEC_API apt_image_t apt_normalize(const float *data, size_t rows, apt_satellite_t satellite, int *error); +// Data is arranged so that each row starts at APTDEC_IMG_WIDTH*y +APTDEC_API aptdec_image_t aptdec_normalize(const float *data, size_t rows, aptdec_satellite_t satellite, int *error); // Get an entire row of pixels -// Requires that `row` has enough space to store APT_IMG_WIDTH*2 +// Requires that `row` has enough space to store APTDEC_IMG_WIDTH*2 // Returns 0 when `callback` return value != count -APTDEC_API int aptdec_getrow(aptdec_t *apt, float *row, aptdec_callback_t callback, void *context); +APTDEC_API int aptdec_getrow(aptdec_t *aptdec, float *row, aptdec_callback_t callback, void *context); // Calibrate channels -APTDEC_API int apt_calibrate_thermal(apt_image_t *img, apt_region_t region); -APTDEC_API int apt_calibrate_visible(apt_image_t *img, apt_region_t region); +APTDEC_API int aptdec_calibrate_thermal(aptdec_image_t *img, aptdec_region_t region); +APTDEC_API int aptdec_calibrate_visible(aptdec_image_t *img, aptdec_region_t region); -APTDEC_API void apt_denoise (apt_image_t *img, apt_region_t region); -APTDEC_API void apt_flip (apt_image_t *img, apt_region_t region); -APTDEC_API void apt_stretch (apt_image_t *img, apt_region_t region); -APTDEC_API void apt_equalize(apt_image_t *img, apt_region_t region); -APTDEC_API int apt_crop (apt_image_t *img); +APTDEC_API void aptdec_denoise (aptdec_image_t *img, aptdec_region_t region); +APTDEC_API void aptdec_flip (aptdec_image_t *img, aptdec_region_t region); +APTDEC_API void aptdec_stretch (aptdec_image_t *img, aptdec_region_t region); +APTDEC_API void aptdec_equalize(aptdec_image_t *img, aptdec_region_t region); +APTDEC_API int aptdec_crop (aptdec_image_t *img); +APTDEC_API void aptdec_strip (aptdec_image_t* img); // Composite two RGB values as layers, in most cases bottom_a will be 1.0f -APTDEC_API apt_rgb_t apt_composite_rgb(apt_rgb_t top, float top_a, apt_rgb_t bottom, float bottom_a); +APTDEC_API aptdec_rgb_t aptdec_composite_rgb(aptdec_rgb_t top, float top_a, aptdec_rgb_t bottom, float bottom_a); -// Apply a gradient such as temperature_gradient +// Apply a gradient such as aptdec_temperature_gradient // If gradient is less than 256 elements it is the callers responsibility // that `val` does not exceed the length of the gradient -APTDEC_API apt_rgb_t apt_gradient(const uint32_t *gradient, uint8_t val); +APTDEC_API aptdec_rgb_t aptdec_gradient(const uint32_t *gradient, uint8_t val); -static const apt_region_t APT_REGION_CHA = { APT_CHA_OFFSET, APT_CH_WIDTH }; -static const apt_region_t APT_REGION_CHB = { APT_CHB_OFFSET, APT_CH_WIDTH }; -static const apt_region_t APT_REGION_CHA_FULL = { 0, APT_IMG_WIDTH/2 }; -static const apt_region_t APT_REGION_CHB_FULL = { APT_IMG_WIDTH/2, APT_IMG_WIDTH/2 }; -static const apt_region_t APT_REGION_FULL = { 0, APT_IMG_WIDTH }; +static const aptdec_region_t APTDEC_REGION_CHA = { APTDEC_CHA_OFFSET, APTDEC_CH_WIDTH }; +static const aptdec_region_t APTDEC_REGION_CHB = { APTDEC_CHB_OFFSET, APTDEC_CH_WIDTH }; +static const aptdec_region_t APTDEC_REGION_CHA_FULL = { 0, APTDEC_IMG_WIDTH/2 }; +static const aptdec_region_t APTDEC_REGION_CHB_FULL = { APTDEC_IMG_WIDTH/2, APTDEC_IMG_WIDTH/2 }; +static const aptdec_region_t APTDEC_REGION_FULL = { 0, APTDEC_IMG_WIDTH }; -APTDEC_API extern const uint32_t temperature_gradient[256]; -APTDEC_API extern const uint32_t precipitation_gradient[58]; +APTDEC_API extern const uint32_t aptdec_temperature_gradient[256]; +APTDEC_API extern const uint32_t aptdec_precipitation_gradient[58]; #ifdef __cplusplus }