summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorrimio <vasi.vilvoiu@gmail.com>2019-01-08 13:52:23 +0200
committerrimio <vasi.vilvoiu@gmail.com>2019-01-08 13:52:23 +0200
commita7d5e7ca20c959b739d80f96362f326a5848cdb3 (patch)
tree5fcc392e5e2b6f425bf3ea756801b7aa9fb81b43 /src/tools
parent83608e80322642e681918a647ef54a67e7bb15a3 (diff)
Image management
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/sstv-encode.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/tools/sstv-encode.cpp b/src/tools/sstv-encode.cpp
index b621a5c..9c7c141 100644
--- a/src/tools/sstv-encode.cpp
+++ b/src/tools/sstv-encode.cpp
@@ -42,20 +42,28 @@ int main(int argc, char **argv)
LOG(FATAL) << "Encoding mode not provided, use --mode";
}
- /* load image */
+ /* TODO: parse SSTV mode */
+ sstv_mode_t mode = SSTV_MODE_PD120;
+
+ /* load image from file (TODO: perform normalization from source to desired properties) */
LOG(INFO) << "Loading image from " << FLAGS_input;
- cimg_library::CImg<unsigned char> input_image(FLAGS_input.c_str());
- uint8_t *bytes = input_image.data();
+ cimg_library::CImg<unsigned char> input_image = (cimg_library::CImg<>(FLAGS_input.c_str())).RGBtoYCbCr();
+
+ sstv_image_t sstv_image;
+ if (sstv_pack_image(&sstv_image, input_image.width(), input_image.height(), SSTV_FORMAT_YCBCR, input_image.data()) != SSTV_OK) {
+ LOG(FATAL) << "sstv_pack_image() failed";
+ }
- /* initialize an encoder */
+ /* initialize library */
LOG(INFO) << "Initializing libsstv";
if (sstv_init(malloc, free) != SSTV_OK) {
LOG(FATAL) << "Failed to initialize libsstv";
}
+ /* create encoder context */
LOG(INFO) << "Creating encoding context";
void *ctx = nullptr;
- if (sstv_create_encoder(SSTV_PD120, bytes, FLAGS_sample_rate, &ctx) != SSTV_OK) {
+ if (sstv_create_encoder(&ctx, sstv_image, mode, FLAGS_sample_rate) != SSTV_OK) {
LOG(FATAL) << "Failed to create SSTV encoder";
}
if (!ctx) {