incremental
diff --git a/include/aspeed/JTABLES.H b/include/aspeed/JTABLES.H
index 93fec8c..bff39e3 100644
--- a/include/aspeed/JTABLES.H
+++ b/include/aspeed/JTABLES.H
@@ -1,11 +1,11 @@
-
-static unsigned char zigzag[64] = {
+#pragma once
+static const unsigned char zigzag[64] = {
0, 1, 5, 6, 14, 15, 27, 28, 2, 4, 7, 13, 16, 26, 29, 42,
3, 8, 12, 17, 25, 30, 41, 43, 9, 11, 18, 24, 31, 40, 44, 53,
10, 19, 23, 32, 39, 45, 52, 54, 20, 22, 33, 38, 46, 51, 55, 60,
21, 34, 37, 47, 50, 56, 59, 61, 35, 36, 48, 49, 57, 58, 62, 63};
-static unsigned char dezigzag[64 + 15] = {
+static const unsigned char dezigzag[64 + 15] = {
0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, 12, 19, 26, 33, 40,
48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61,
@@ -13,24 +13,24 @@
// let corrupt input sample past end
63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63};
-static unsigned char *std_luminance_qt;
-static unsigned char *std_chrominance_qt;
+static const unsigned char *std_luminance_qt;
+static const unsigned char *std_chrominance_qt;
// Standard Huffman tables (cf. JPEG standard section K.3) */
-static unsigned char std_dc_luminance_nrcodes[17] = {0, 0, 1, 5, 1, 1, 1, 1, 1,
+static const unsigned char std_dc_luminance_nrcodes[17] = {0, 0, 1, 5, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0};
-static unsigned char std_dc_luminance_values[12] = {0, 1, 2, 3, 4, 5,
+static const unsigned char std_dc_luminance_values[12] = {0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11};
-static unsigned char std_dc_chrominance_nrcodes[17] = {
+static const unsigned char std_dc_chrominance_nrcodes[17] = {
0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0};
-static unsigned char std_dc_chrominance_values[12] = {0, 1, 2, 3, 4, 5,
+static const unsigned char std_dc_chrominance_values[12] = {0, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11};
-static unsigned char std_ac_luminance_nrcodes[17] = {
+static const unsigned char std_ac_luminance_nrcodes[17] = {
0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d};
-static unsigned char std_ac_luminance_values[162] = {
+static const unsigned char std_ac_luminance_values[162] = {
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06,
0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72,
@@ -46,9 +46,9 @@
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4,
0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa};
-static unsigned char std_ac_chrominance_nrcodes[17] = {
+static const unsigned char std_ac_chrominance_nrcodes[17] = {
0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77};
-static unsigned char std_ac_chrominance_values[162] = {
+static const unsigned char std_ac_chrominance_values[162] = {
0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41,
0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1,
@@ -64,7 +64,7 @@
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4,
0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa};
-unsigned short int DC_LUMINANCE_HUFFMANCODE[13 * 2] = {
+static const unsigned short int DC_LUMINANCE_HUFFMANCODE[13 * 2] = {
/* 0 */ 0x0000, 0,
/* 1 */ 0x4000, 2,
/* 2 */ 0x6000, 3,
@@ -80,7 +80,7 @@
/* 12 */ 0xFFFF, 9,
};
-unsigned short int DC_CHROMINANCE_HUFFMANCODE[13 * 2] = {
+static const unsigned short int DC_CHROMINANCE_HUFFMANCODE[13 * 2] = {
/* 0 */ 0x0000, 0,
/* 1 */ 0x4000, 2,
/* 2 */ 0x8000, 2,
@@ -96,7 +96,7 @@
/* 12 */ 0xFFFF, 11,
};
-unsigned short int AC_LUMINANCE_HUFFMANCODE[39 * 2] = {
+static const unsigned short int AC_LUMINANCE_HUFFMANCODE[39 * 2] = {
/* 0 */ 0x0000, 0,
/* 1 */ 0x4000, 2,
/* 2 */ 0x8000, 2,
@@ -138,7 +138,7 @@
/* 38 */ 0xFFFF, 16,
};
-unsigned short int AC_CHROMINANCE_HUFFMANCODE[45 * 2] = {
+static const unsigned short int AC_CHROMINANCE_HUFFMANCODE[45 * 2] = {
/* 0 */ 0x0000, 0,
/* 1 */ 0x4000, 2,
/* 2 */ 0x8000, 2,
@@ -187,59 +187,59 @@
};
//[100]=========================
-static unsigned char Tbl_100Y[64] = {
+static const unsigned char Tbl_100Y[64] = {
2, 1, 1, 2, 3, 5, 6, 7, 1, 1, 1, 2, 3, 7, 7, 6,
1, 1, 2, 3, 5, 7, 8, 7, 1, 2, 2, 3, 6, 10, 10, 7,
2, 2, 4, 7, 8, 13, 12, 9, 3, 4, 6, 8, 10, 13, 14, 11,
6, 8, 9, 10, 12, 15, 15, 12, 9, 11, 11, 12, 14, 12, 12, 12};
-static unsigned char Tbl_100UV[64] = {
+static const unsigned char Tbl_100UV[64] = {
3, 3, 4, 8, 18, 18, 18, 18, 3, 3, 4, 12, 18, 18, 18, 18,
4, 4, 10, 18, 18, 18, 18, 18, 8, 12, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18};
//[086]=========================
-static unsigned char Tbl_086Y[64] = {
+static const unsigned char Tbl_086Y[64] = {
3, 2, 1, 3, 4, 7, 9, 11, 2, 2, 2, 3, 4, 10, 11, 10,
2, 2, 3, 4, 7, 10, 12, 10, 2, 3, 4, 5, 9, 16, 15, 11,
3, 4, 6, 10, 12, 20, 19, 14, 4, 6, 10, 12, 15, 19, 21, 17,
9, 12, 14, 16, 19, 22, 22, 18, 13, 17, 17, 18, 21, 18, 19, 18};
-static unsigned char Tbl_086UV[64] = {
+static const unsigned char Tbl_086UV[64] = {
4, 5, 6, 13, 27, 27, 27, 27, 5, 5, 7, 18, 27, 27, 27, 27,
6, 7, 15, 27, 27, 27, 27, 27, 13, 18, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27};
//[071]=========================
-static unsigned char Tbl_071Y[64] = {
+static const unsigned char Tbl_071Y[64] = {
6, 4, 3, 6, 9, 15, 19, 22, 4, 4, 5, 7, 9, 21, 22, 20,
5, 4, 6, 9, 15, 21, 25, 21, 5, 6, 8, 10, 19, 32, 30, 23,
6, 8, 13, 21, 25, 40, 38, 28, 9, 13, 20, 24, 30, 39, 42, 34,
18, 24, 29, 32, 38, 45, 45, 37, 27, 34, 35, 36, 42, 37, 38, 37};
-static unsigned char Tbl_071UV[64] = {
+static const unsigned char Tbl_071UV[64] = {
9, 10, 13, 26, 55, 55, 55, 55, 10, 11, 14, 37, 55, 55, 55, 55,
13, 14, 31, 55, 55, 55, 55, 55, 26, 37, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55};
//[057]=========================
-static unsigned char Tbl_057Y[64] = {
+static const unsigned char Tbl_057Y[64] = {
9, 6, 5, 9, 13, 22, 28, 34, 6, 6, 7, 10, 14, 32, 33, 30,
7, 7, 9, 13, 22, 32, 38, 31, 7, 9, 12, 16, 28, 48, 45, 34,
10, 12, 20, 31, 38, 61, 57, 43, 13, 19, 30, 36, 45, 58, 63, 51,
27, 36, 43, 48, 57, 68, 67, 56, 40, 51, 53, 55, 63, 56, 57, 55};
-static unsigned char Tbl_057UV[64] = {
+static const unsigned char Tbl_057UV[64] = {
13, 14, 19, 38, 80, 80, 80, 80, 14, 17, 21, 53, 80, 80, 80, 80,
19, 21, 45, 80, 80, 80, 80, 80, 38, 53, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80};
//[043]=========================
-static unsigned char Tbl_043Y[64] = {
+static const unsigned char Tbl_043Y[64] = {
11, 7, 7, 11, 17, 28, 36, 43, 8, 8, 10, 13, 18, 41, 43, 39,
10, 9, 11, 17, 28, 40, 49, 40, 10, 12, 15, 20, 36, 62, 57, 44,
12, 15, 26, 40, 48, 78, 74, 55, 17, 25, 39, 46, 58, 74, 81, 66,
35, 46, 56, 62, 74, 86, 86, 72, 51, 66, 68, 70, 80, 71, 74, 71};
-static unsigned char Tbl_043UV[64] = {
+static const unsigned char Tbl_043UV[64] = {
18, 19, 26, 51, 108, 108, 108, 108, 19, 22, 28, 72, 108,
108, 108, 108, 26, 28, 61, 108, 108, 108, 108, 108, 51, 72,
108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108,
@@ -247,12 +247,12 @@
108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108};
//[029]=========================
-static unsigned char Tbl_029Y[64] = {
+static const unsigned char Tbl_029Y[64] = {
14, 9, 9, 14, 21, 36, 46, 55, 10, 10, 12, 17, 23, 52, 54, 49,
12, 11, 14, 21, 36, 51, 62, 50, 12, 15, 19, 26, 46, 78, 72, 56,
16, 19, 33, 50, 61, 98, 93, 69, 21, 31, 49, 58, 73, 94, 102, 83,
44, 58, 70, 78, 93, 109, 108, 91, 65, 83, 86, 88, 101, 90, 93, 89};
-static unsigned char Tbl_029UV[64] = {
+static const unsigned char Tbl_029UV[64] = {
22, 24, 32, 63, 133, 133, 133, 133, 24, 28, 34, 88, 133,
133, 133, 133, 32, 34, 75, 133, 133, 133, 133, 133, 63, 88,
133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
@@ -260,24 +260,24 @@
133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133, 133};
//[014]=========================
-static unsigned char Tbl_014Y[64] = {
+static const unsigned char Tbl_014Y[64] = {
17, 12, 10, 17, 26, 43, 55, 66, 13, 13, 15, 20, 28, 63, 65, 60,
15, 14, 17, 26, 43, 62, 75, 61, 15, 18, 24, 31, 55, 95, 87, 67,
19, 24, 40, 61, 74, 119, 112, 84, 26, 38, 60, 70, 88, 113, 123, 100,
53, 70, 85, 95, 112, 132, 131, 110, 78, 100, 103, 107, 122, 109, 112, 108};
-static unsigned char Tbl_014UV[64] = {
+static const unsigned char Tbl_014UV[64] = {
27, 29, 39, 76, 160, 160, 160, 160, 29, 34, 42, 107, 160,
160, 160, 160, 39, 42, 91, 160, 160, 160, 160, 160, 76, 107,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160};
//[000]=========================
-static unsigned char Tbl_000Y[64] = {
+static const unsigned char Tbl_000Y[64] = {
20, 13, 12, 20, 30, 50, 63, 76, 15, 15, 17, 23, 32, 72, 75, 68,
17, 16, 20, 30, 50, 71, 86, 70, 17, 21, 27, 36, 63, 108, 100, 77,
22, 27, 46, 70, 85, 136, 128, 96, 30, 43, 68, 80, 101, 130, 141, 115,
61, 80, 97, 108, 128, 151, 150, 126, 90, 115, 118, 122, 140, 125, 128, 123};
-static unsigned char Tbl_000UV[64] = {
+static const unsigned char Tbl_000UV[64] = {
31, 33, 45, 88, 185, 185, 185, 185, 33, 39, 48, 123, 185,
185, 185, 185, 45, 48, 105, 185, 185, 185, 185, 185, 88, 123,
185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
diff --git a/include/ast_jpeg_decoder.hpp b/include/ast_jpeg_decoder.hpp
index 4036423..6e5a3d4 100644
--- a/include/ast_jpeg_decoder.hpp
+++ b/include/ast_jpeg_decoder.hpp
@@ -73,8 +73,8 @@
public:
AstJpegDecoder() {
// TODO(ed) figure out how to init this in the constructor
- YUVBuffer.resize(800 * 600);
- OutBuffer.resize(800 * 600);
+ YUVBuffer.resize(1920 * 1200);
+ OutBuffer.resize(1920 * 1200);
for (auto &r : OutBuffer) {
r.R = 0x00;
r.G = 0x00;
@@ -815,8 +815,9 @@
}
*/
}
- void load_Huffman_table(Huffman_table *HT, unsigned char *nrcode,
- unsigned char *value, unsigned short int *Huff_code) {
+ void load_Huffman_table(Huffman_table *HT, const unsigned char *nrcode,
+ const unsigned char *value,
+ const unsigned short int *Huff_code) {
unsigned char k, j, i;
unsigned int code, code_index;
@@ -1001,7 +1002,7 @@
return 1;
}
- void set_quant_table(uint8_t *basic_table, uint8_t scale_factor,
+ void set_quant_table(const uint8_t *basic_table, uint8_t scale_factor,
uint8_t *newtable)
// Set quantization table and zigzag reorder it
{
@@ -1307,8 +1308,8 @@
std::array<int, 256> m_Y;
unsigned long buffer_index;
uint32_t codebuf, newbuf, readbuf;
- uint8_t *std_luminance_qt;
- uint8_t *std_chrominance_qt;
+ const unsigned char *std_luminance_qt;
+ const uint8_t *std_chrominance_qt;
signed short int DCY, DCCb, DCCr; // Coeficientii DC pentru Y,Cb,Cr
signed short int DCT_coeff[384];
diff --git a/include/crow/g3_logger.hpp b/include/crow/g3_logger.hpp
index 8980207..748328e 100644
--- a/include/crow/g3_logger.hpp
+++ b/include/crow/g3_logger.hpp
@@ -1,8 +1,10 @@
#pragma once
// This file overrides the default crow logging framework to use g3 instead.
-// It implements enough of the interfaces of the crow logging framework to work correctly
-// but deletes the ILogHandler interface, as usage of that would be counter to the g3
+// It implements enough of the interfaces of the crow logging framework to work
+// correctly
+// but deletes the ILogHandler interface, as usage of that would be counter to
+// the g3
// handler management, and would cause performance issues.
#include <cstdio>
@@ -45,7 +47,7 @@
}
//
- static void setLogLevel(LogLevel level) { }
+ static void setLogLevel(LogLevel level) {}
static LogLevel get_current_log_level() { return get_log_level_ref(); }
@@ -61,29 +63,17 @@
LogLevel level_;
};
}
+#ifndef CROW_DISABLE_LOGGING
+#define CROW_DISABLE_LOGGING false
+#endif
-#define CROW_LOG_CRITICAL LOG(FATAL)
-#define CROW_LOG_ERROR LOG(WARNING)
-#define CROW_LOG_WARNING LOG(WARNING)
-#define CROW_LOG_INFO LOG(INFO)
-#define CROW_LOG_DEBUG LOG(DEBUG)
-
-
-
-/*
-#define CROW_LOG_CRITICAL \
- if (false) \
- crow::logger("CRITICAL", crow::LogLevel::Critical)
-#define CROW_LOG_ERROR \
- if (false) \
- crow::logger("ERROR ", crow::LogLevel::Error)
-#define CROW_LOG_WARNING \
- if (false) \
- crow::logger("WARNING ", crow::LogLevel::Warning)
-#define CROW_LOG_INFO \
- if (false) \
- crow::logger("INFO ", crow::LogLevel::Info)
-#define CROW_LOG_DEBUG \
- if (false) \
- crow::logger("DEBUG ", crow::LogLevel::Debug)
-*/
\ No newline at end of file
+#define CROW_LOG_CRITICAL \
+ if (!CROW_DISABLE_LOGGING) LOG(FATAL)
+#define CROW_LOG_ERROR \
+ if (!CROW_DISABLE_LOGGING) LOG(WARNING)
+#define CROW_LOG_WARNING \
+ if (!CROW_DISABLE_LOGGING) LOG(WARNING)
+#define CROW_LOG_INFO \
+ if (!CROW_DISABLE_LOGGING) LOG(INFO)
+#define CROW_LOG_DEBUG \
+ if (!CROW_DISABLE_LOGGING) LOG(DEBUG)
diff --git a/include/test_utils.hpp b/include/test_utils.hpp
new file mode 100644
index 0000000..eb990d5
--- /dev/null
+++ b/include/test_utils.hpp
@@ -0,0 +1,6 @@
+#pragma once
+
+#include <string>
+
+bool gzipInflate(const std::string& compressedBytes,
+ std::string& uncompressedBytes);
\ No newline at end of file
diff --git a/include/web_kvm.hpp b/include/web_kvm.hpp
index 62be097..df0bef5 100644
--- a/include/web_kvm.hpp
+++ b/include/web_kvm.hpp
@@ -51,6 +51,14 @@
client_cut_text = 6
};
+enum class server_to_client_message_type : uint8_t
+{
+ framebuffer_update = 0,
+ set_color_map_entries = 1,
+ bell_message = 2,
+ server_cut_text = 3
+};
+
struct set_pixel_format_msg {
boost::endian::big_uint8_t pad1;
boost::endian::big_uint8_t pad2;
@@ -135,7 +143,7 @@
std::string serialized(vector_size, 0);
size_t i = 0;
- serialized[i++] = 0; // Type
+ serialized[i++] = static_cast<char>(server_to_client_message_type::framebuffer_update); // Type
serialized[i++] = 0; // Pad byte
boost::endian::big_uint16_t number_of_rectangles = msg.rectangles.size();
std::memcpy(&serialized[i], &number_of_rectangles,
@@ -271,47 +279,47 @@
auto msg = reinterpret_cast<const frame_buffer_update_req*>(
data.data() + sizeof(client_to_server_msg_type));
- // Todo(ed) lifecycle of the video puller and decoder
- // should be
- // with the websocket, not recreated every time
- AstVideo::VideoPuller p;
- p.initialize();
- auto out = p.read_video();
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode,
- out.y_selector, out.uv_selector);
+ // Todo(ed) lifecycle of the video puller and decoder
+ // should be
+ // with the websocket, not recreated every time
+ AstVideo::VideoPuller p;
+ p.initialize();
+ auto out = p.read_video();
+ AstVideo::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode,
+ out.y_selector, out.uv_selector);
- framebuffer_update_msg buffer_update_msg;
+ framebuffer_update_msg buffer_update_msg;
- // If the viewer is requesting a full update, force write
- // of all pixels
+ // If the viewer is requesting a full update, force write
+ // of all pixels
- framebuffer_rectangle this_rect;
- this_rect.x = msg->x_position;
- this_rect.y = msg->y_position;
- this_rect.width = out.width;
- this_rect.height = out.height;
- this_rect.encoding =
- static_cast<uint8_t>(encoding_type::raw);
- LOG(DEBUG) << "Encoding is " << this_rect.encoding;
- this_rect.data.reserve(this_rect.width *
- this_rect.height * 4);
- LOG(DEBUG) << "Width " << out.width << " Height "
- << out.height;
+ framebuffer_rectangle this_rect;
+ this_rect.x = msg->x_position;
+ this_rect.y = msg->y_position;
+ this_rect.width = out.width;
+ this_rect.height = out.height;
+ this_rect.encoding =
+ static_cast<uint8_t>(encoding_type::raw);
+ LOG(DEBUG) << "Encoding is " << this_rect.encoding;
+ this_rect.data.reserve(this_rect.width * this_rect.height *
+ 4);
+ LOG(DEBUG) << "Width " << out.width << " Height "
+ << out.height;
- for (int i = 0; i < out.width * out.height; i++) {
- auto& pixel = d.OutBuffer[i];
- this_rect.data.push_back(pixel.B);
- this_rect.data.push_back(pixel.G);
- this_rect.data.push_back(pixel.R);
- this_rect.data.push_back(0);
- }
+ for (int i = 0; i < out.width * out.height; i++) {
+ auto& pixel = d.OutBuffer[i];
+ this_rect.data.push_back(pixel.B);
+ this_rect.data.push_back(pixel.G);
+ this_rect.data.push_back(pixel.R);
+ this_rect.data.push_back(0);
+ }
- buffer_update_msg.rectangles.push_back(
- std::move(this_rect));
- auto serialized = serialize(buffer_update_msg);
+ buffer_update_msg.rectangles.push_back(
+ std::move(this_rect));
+ auto serialized = serialize(buffer_update_msg);
- conn.send_binary(serialized);
+ conn.send_binary(serialized);
} // TODO(Ed) handle error