From a7d5e7ca20c959b739d80f96362f326a5848cdb3 Mon Sep 17 00:00:00 2001 From: rimio Date: Tue, 8 Jan 2019 13:52:23 +0200 Subject: Image management --- src/tools/sstv-encode.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/tools/sstv-encode.cpp') 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 input_image(FLAGS_input.c_str()); - uint8_t *bytes = input_image.data(); + cimg_library::CImg 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) { -- cgit v1.2.3