2017-04-08 20:50:18 +02:00
|
|
|
/* -*- c++ -*- */
|
2017-07-19 15:57:00 +02:00
|
|
|
/*
|
|
|
|
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017, Libre Space Foundation <http://librespacefoundation.org/>
|
|
|
|
*
|
|
|
|
* 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 3 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 <http://www.gnu.org/licenses/>.
|
2017-04-08 20:50:18 +02:00
|
|
|
*/
|
|
|
|
|
2017-04-09 18:25:37 +02:00
|
|
|
#ifndef INCLUDED_SATNOGS_NOAA_APT_SINK_IMPL_H
|
|
|
|
#define INCLUDED_SATNOGS_NOAA_APT_SINK_IMPL_H
|
2017-04-08 20:50:18 +02:00
|
|
|
|
2017-04-09 18:25:37 +02:00
|
|
|
#include <satnogs/noaa_apt_sink.h>
|
2017-04-10 14:01:02 +02:00
|
|
|
#define PNG_DEBUG 3
|
|
|
|
#include <png.h>
|
2017-08-07 13:28:40 +02:00
|
|
|
#include <chrono>
|
2017-04-08 20:50:18 +02:00
|
|
|
|
2017-04-09 18:25:37 +02:00
|
|
|
namespace gr
|
|
|
|
{
|
|
|
|
namespace satnogs
|
|
|
|
{
|
2017-04-08 20:50:18 +02:00
|
|
|
|
2017-04-09 18:25:37 +02:00
|
|
|
class noaa_apt_sink_impl : public noaa_apt_sink
|
2017-04-08 20:50:18 +02:00
|
|
|
{
|
2017-04-09 18:25:37 +02:00
|
|
|
private:
|
2017-04-08 20:50:18 +02:00
|
|
|
uint32_t d_sync_word;
|
|
|
|
uint32_t d_constructed_word;
|
|
|
|
float d_slicer_threshold;
|
|
|
|
bool d_sync_found;
|
|
|
|
float d_max_value;
|
|
|
|
float d_min_value;
|
|
|
|
size_t d_norm_window;
|
|
|
|
size_t d_sample_counter;
|
|
|
|
const char* d_filename_png;
|
|
|
|
size_t d_width;
|
|
|
|
size_t d_height;
|
2017-04-09 16:20:02 +02:00
|
|
|
bool d_split;
|
2017-04-10 14:01:02 +02:00
|
|
|
size_t d_history_length;
|
|
|
|
bool d_synchronize_opt;
|
|
|
|
png_structp* d_png_ptr;
|
|
|
|
png_infop* d_info_ptr;
|
|
|
|
uint8_t* d_row_buffer;
|
|
|
|
png_byte d_color_type;
|
|
|
|
png_byte d_bit_depth;
|
2017-04-10 17:03:00 +02:00
|
|
|
FILE** d_png_fd;
|
2017-04-10 14:01:02 +02:00
|
|
|
size_t d_images_per_frame;
|
|
|
|
size_t d_row_counter;
|
|
|
|
size_t d_num_images;
|
|
|
|
size_t d_current_buffered_samples;
|
2017-04-10 17:03:00 +02:00
|
|
|
std::vector<std::string> d_png_fn;
|
|
|
|
bool d_flip;
|
|
|
|
|
2017-04-09 18:25:37 +02:00
|
|
|
public:
|
2017-07-19 15:57:00 +02:00
|
|
|
noaa_apt_sink_impl (const char *filename_png, size_t width, size_t height,
|
|
|
|
bool split, bool sync, bool flip);
|
2017-04-09 18:25:37 +02:00
|
|
|
~noaa_apt_sink_impl ();
|
|
|
|
void
|
2017-04-10 14:01:02 +02:00
|
|
|
write_png_row ();
|
|
|
|
void
|
|
|
|
init_png ();
|
2017-04-10 17:03:00 +02:00
|
|
|
void
|
2017-07-19 15:57:00 +02:00
|
|
|
flip_image ();
|
2017-04-08 20:50:18 +02:00
|
|
|
|
|
|
|
// Where all the action really happens
|
2017-04-09 18:25:37 +02:00
|
|
|
int
|
|
|
|
work (int noutput_items, gr_vector_const_void_star &input_items,
|
2017-07-19 15:57:00 +02:00
|
|
|
gr_vector_void_star &output_items);
|
2017-04-08 20:50:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace satnogs
|
|
|
|
} // namespace gr
|
|
|
|
|
2017-04-09 18:25:37 +02:00
|
|
|
#endif /* INCLUDED_SATNOGS_NOAA_APT_SINK_IMPL_H */
|
2017-04-08 20:50:18 +02:00
|
|
|
|