/* * Copyright (c) 2018 Vasile Vilvoiu (YO7JBP) * * libsstv is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. */ #include #include #include #include #include #include extern "C" { #include } /* * Command line flags */ DEFINE_bool(logtostderr, false, "Only log to stderr"); DEFINE_string(mode, "", "SSTV mode for encoder"); DEFINE_string(input, "", "input image"); DEFINE_string(output, "", "output WAV file"); DEFINE_uint64(sample_rate, 48000, "output audio sample rate"); int main(int argc, char **argv) { /* Parse command line flags */ gflags::ParseCommandLineFlags(&argc, &argv, true); /* Initialize logging */ google::InitGoogleLogging(argv[0]); google::InstallFailureSignalHandler(); /* check input */ if (FLAGS_input == "") { LOG(FATAL) << "Input image filename not provided, use --input"; } if (FLAGS_output == "") { LOG(FATAL) << "Output WAV file not provided, use --output"; } if (FLAGS_mode == "") { LOG(FATAL) << "Encoding mode not provided, use --mode"; } /* TODO: parse SSTV mode */ sstv_mode_t mode = SSTV_MODE_PD120; /* get image properties for chosen mode */ size_t width, height; sstv_image_format_t format; if (sstv_get_mode_image_props(mode, &width, &height, &format) != SSTV_OK) { LOG(FATAL) << "sstv_get_mode_image_props() failed"; } /* load image from file */ LOG(INFO) << "Loading image from " << FLAGS_input; Magick::Image image; uint8_t *image_buffer = NULL; try { /* load from file */ image.read(FLAGS_input); /* resize */ LOG(INFO) << "Resizing to " << width << "x"<