Always re-encode the image in image_streamer
Makes it so we can change the compression
Change-Id: Ibbf4b7e25eb8a3bb70d3256fbc09bcf1a580ea40
diff --git a/y2019/image_streamer/flip_image.cc b/y2019/image_streamer/flip_image.cc
index 6ff00ed..2db20b2 100644
--- a/y2019/image_streamer/flip_image.cc
+++ b/y2019/image_streamer/flip_image.cc
@@ -6,10 +6,12 @@
#include "third_party/cimg/CImg.h"
void flip_image(const char *input, const int input_size, JOCTET *buffer,
- unsigned int *buffer_size) {
+ unsigned int *buffer_size, bool flip) {
::cimg_library::CImg<unsigned char> image;
image.load_jpeg_buffer((JOCTET *)(input), input_size);
- image.mirror("xy");
+ if (flip) {
+ image.mirror("xy");
+ }
image.save_jpeg_buffer(buffer, *buffer_size, 80);
}
diff --git a/y2019/image_streamer/flip_image.h b/y2019/image_streamer/flip_image.h
index 6a59e96..7c31774 100644
--- a/y2019/image_streamer/flip_image.h
+++ b/y2019/image_streamer/flip_image.h
@@ -7,6 +7,6 @@
#include "third_party/libjpeg/jpeglib.h"
void flip_image(const char *input, const int input_size, JOCTET *buffer,
- unsigned int *buffer_size);
+ unsigned int *buffer_size, bool flip_image);
#endif // Y2019_IMAGE_STREAMER_FLIP_IMAGE_H
diff --git a/y2019/image_streamer/image_streamer.cc b/y2019/image_streamer/image_streamer.cc
index ed581e2..ebcd0b2 100644
--- a/y2019/image_streamer/image_streamer.cc
+++ b/y2019/image_streamer/image_streamer.cc
@@ -280,15 +280,12 @@
sampling = 0;
}
- std::string image_out;
+ ::std::string image_out;
- if (flip_) {
- unsigned int out_size = image_buffer_out_.size();
- flip_image(data.data(), data.size(), &image_buffer_out_[0], &out_size);
- image_out.assign(&image_buffer_out_[0], &image_buffer_out_[out_size]);
- } else {
- image_out = std::string(data);
- }
+ unsigned int out_size = image_buffer_out_.size();
+ flip_image(data.data(), data.size(), &image_buffer_out_[0], &out_size,
+ flip_);
+ image_out.assign(&image_buffer_out_[0], &image_buffer_out_[out_size]);
if (active_) {
auto frame = std::make_shared<Frame>(Frame{image_out});