Implement optional per-frame CRC calculation to save bandwidth

Current implementation is very CPU-efficient as it's not processing
JPEG-encoded data received from V4L2 at all.

This patch implements an optional mode where for each frame that's about
to be sent a CRC32 is calculated and if this client has already received
it before, the transmission is skipped. This of course adds some
noticeable CPU load (proportional to the frame rate requested and the
encoded JPEG size); on AST2500 it's taking about 10 % CPU when showing a
relatively complex GUI login screen with 15 FPS.

Reducing required bandwidth to 0 for static images helps a lot when
using IP KVM via poor connections, e.g. provided by cellular network
operators or some hotels, so can be beneficial for certain common
usecases.

The next optimisation to try is to dynamically alter the frame rate,
automatically ramping it up as soon as the changes start happening and
lowering after a period of inactivity; it's not yet clear if V4L2 allows
this.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Change-Id: I74b887cf83b5c8676f5792412805de08e1a54f32
diff --git a/ikvm_server.hpp b/ikvm_server.hpp
index ebe4ad2..bfeb73b 100644
--- a/ikvm_server.hpp
+++ b/ikvm_server.hpp
@@ -30,7 +30,7 @@
          * @param[in] s - Number of frames to skip when client connects
          * @param[in] i - Pointer to Input object
          */
-        ClientData(int s, Input* i) : skipFrame(s), input(i)
+        ClientData(int s, Input* i) : skipFrame(s), input(i), last_crc{-1}
         {
             needUpdate = false;
         }
@@ -43,6 +43,7 @@
         int skipFrame;
         Input* input;
         bool needUpdate;
+        int64_t last_crc;
     };
 
     /*
@@ -127,6 +128,8 @@
     Video& video;
     /* @brief Default framebuffer storage */
     std::vector<char> framebuffer;
+    /* @brief Identical frames detection */
+    bool calcFrameCRC;
     /* @brief Cursor bitmap width */
     static constexpr int cursorWidth = 20;
     /* @brief Cursor bitmap height */