From 65b6c374e716878c46f7ff8ee86f25a5807c29cd Mon Sep 17 00:00:00 2001 From: Stefan Pöschel Date: Thu, 24 Aug 2017 10:15:31 +0200 Subject: Make data group apptypes constants --- src/dls.cpp | 9 ++++++--- src/dls.h | 3 +++ src/pad_common.cpp | 3 ++- src/pad_common.h | 1 + src/sls.cpp | 4 +++- src/sls.h | 3 +++ 6 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/dls.cpp b/src/dls.cpp index 92c8da4..e5f6f27 100644 --- a/src/dls.cpp +++ b/src/dls.cpp @@ -36,10 +36,13 @@ const size_t DLSEncoder::DLS_SEG_LEN_PREFIX = 2; const size_t DLSEncoder::DLS_SEG_LEN_CHAR_MAX = 16; const std::string DLSEncoder::DL_PARAMS_OPEN = "##### parameters { #####"; const std::string DLSEncoder::DL_PARAMS_CLOSE = "##### parameters } #####"; +const int DLSEncoder::APPTYPE_START = 2; +const int DLSEncoder::APPTYPE_CONT = 3; + DATA_GROUP* DLSEncoder::createDynamicLabelCommand(uint8_t command) { - DATA_GROUP* dg = new DATA_GROUP(2, 2, 3); + DATA_GROUP* dg = new DATA_GROUP(2, APPTYPE_START, APPTYPE_CONT); uint8_vector_t &seg_data = dg->data; // prefix: toggle? + first seg + last seg + command flag + command @@ -62,7 +65,7 @@ DATA_GROUP* DLSEncoder::createDynamicLabelCommand(uint8_t command) { DATA_GROUP* DLSEncoder::createDynamicLabelPlus(const DL_STATE& dl_state) { size_t tags_size = dl_state.dl_plus_tags.size(); size_t len_dl_plus_cmd_field = 1 + 3 * tags_size; - DATA_GROUP* dg = new DATA_GROUP(2 + len_dl_plus_cmd_field, 2, 3); + DATA_GROUP* dg = new DATA_GROUP(2 + len_dl_plus_cmd_field, APPTYPE_START, APPTYPE_CONT); uint8_vector_t &seg_data = dg->data; // prefix: toggle? + first seg + last seg + command flag + command @@ -292,7 +295,7 @@ DATA_GROUP* DLSEncoder::dls_get(const std::string& text, DABCharset charset, int const char *seg_text_start = text.c_str() + seg_text_offset; size_t seg_text_len = std::min(text.size() - seg_text_offset, DLS_SEG_LEN_CHAR_MAX); - DATA_GROUP* dg = new DATA_GROUP(DLS_SEG_LEN_PREFIX + seg_text_len, 2, 3); + DATA_GROUP* dg = new DATA_GROUP(DLS_SEG_LEN_PREFIX + seg_text_len, APPTYPE_START, APPTYPE_CONT); uint8_vector_t &seg_data = dg->data; // prefix: toggle? + first seg? + last seg? + (seg len - 1) diff --git a/src/dls.h b/src/dls.h index e50d02e..135da48 100644 --- a/src/dls.h +++ b/src/dls.h @@ -149,6 +149,9 @@ private: bool dls_toggle; DL_STATE dl_state_prev; public: + static const int APPTYPE_START; + static const int APPTYPE_CONT; + DLSEncoder(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), dls_toggle(false) {} void encodeLabel(const std::string& dls_file, const DL_PARAMS& dl_params); }; diff --git a/src/pad_common.cpp b/src/pad_common.cpp index f60b2eb..13a96ef 100644 --- a/src/pad_common.cpp +++ b/src/pad_common.cpp @@ -81,6 +81,7 @@ const size_t PADPacketizer::SHORT_PAD = 6; // F-PAD + 1x CI const size_t PADPacketizer::VARSIZE_PAD_MIN = 8; // F-PAD + 1x CI + end marker + 1x 4 bytes data sub-field const size_t PADPacketizer::VARSIZE_PAD_MAX = 196; // F-PAD + 4x CI + 4x 48 bytes data sub-field const std::string PADPacketizer::ALLOWED_PADLEN = "6 (short X-PAD), 8 to 196 (variable size X-PAD)"; +const int PADPacketizer::APPTYPE_DGLI = 1; PADPacketizer::PADPacketizer(size_t pad_size) : xpad_size_max(pad_size - FPAD_LEN), @@ -308,7 +309,7 @@ pad_t* PADPacketizer::FlushPAD() { } DATA_GROUP* PADPacketizer::CreateDataGroupLengthIndicator(size_t len) { - DATA_GROUP* dg = new DATA_GROUP(2, 1, 1); // continuation never used (except for comparison at short X-PAD) + DATA_GROUP* dg = new DATA_GROUP(2, APPTYPE_DGLI, APPTYPE_DGLI); // continuation never used (except for comparison at short X-PAD) uint8_vector_t &data = dg->data; // Data Group length diff --git a/src/pad_common.h b/src/pad_common.h index a173d9d..5ee2d80 100644 --- a/src/pad_common.h +++ b/src/pad_common.h @@ -112,6 +112,7 @@ private: pad_t* FlushPAD(); public: static const std::string ALLOWED_PADLEN; + static const int APPTYPE_DGLI; PADPacketizer(size_t pad_size); ~PADPacketizer(); diff --git a/src/sls.cpp b/src/sls.cpp index a401bad..a36c5da 100644 --- a/src/sls.cpp +++ b/src/sls.cpp @@ -255,6 +255,8 @@ const size_t SLSEncoder::MAXSEGLEN = 8189; // Bytes (EN 301 234 v2.1.1, c const size_t SLSEncoder::MAXSLIDESIZE = 51200; // Bytes (TS 101 499 v3.1.1, ch. 9.1.2) const int SLSEncoder::MINQUALITY = 40; // Do not allow the image compressor to go below JPEG quality 40 const std::string SLSEncoder::SLS_PARAMS_SUFFIX = ".sls_params"; +const int SLSEncoder::APPTYPE_MOT_START = 12; +const int SLSEncoder::APPTYPE_MOT_CONT = 13; void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname) { @@ -733,7 +735,7 @@ void SLSEncoder::createMscDG(MSCDG* msc, unsigned short int dgtype, DATA_GROUP* SLSEncoder::packMscDG(MSCDG* msc) { - DATA_GROUP* dg = new DATA_GROUP(9 + msc->seglen, 12, 13); + DATA_GROUP* dg = new DATA_GROUP(9 + msc->seglen, APPTYPE_MOT_START, APPTYPE_MOT_CONT); uint8_vector_t &b = dg->data; // headers diff --git a/src/sls.h b/src/sls.h index 5491c0a..9695544 100644 --- a/src/sls.h +++ b/src/sls.h @@ -245,6 +245,9 @@ private: int cindex_header; int cindex_body; public: + static const int APPTYPE_MOT_START; + static const int APPTYPE_MOT_CONT; + SLSEncoder(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), cindex_header(0), cindex_body(0) {} bool encodeSlide(const std::string& fname, int fidx, bool raw_slides); -- cgit v1.2.3