diff options
author | Stefan Pöschel <github@basicmaster.de> | 2017-08-23 19:02:39 +0200 |
---|---|---|
committer | Stefan Pöschel <github@basicmaster.de> | 2017-08-23 19:02:39 +0200 |
commit | d782b32c7fdd6713af362534cfa5a4d754190b64 (patch) | |
tree | ecb45f294e3ed9ba251d3a9b104ad5cc8fe0f90e | |
parent | 50e051adebc847a338694b53f1d9ea41c8290529 (diff) | |
download | ODR-PadEnc-d782b32c7fdd6713af362534cfa5a4d754190b64.tar.gz ODR-PadEnc-d782b32c7fdd6713af362534cfa5a4d754190b64.tar.bz2 ODR-PadEnc-d782b32c7fdd6713af362534cfa5a4d754190b64.zip |
Rename managers to encoders
-rw-r--r-- | src/dls.cpp | 30 | ||||
-rw-r--r-- | src/dls.h | 8 | ||||
-rw-r--r-- | src/odr-padenc.cpp | 10 | ||||
-rw-r--r-- | src/sls.cpp | 32 | ||||
-rw-r--r-- | src/sls.h | 8 |
5 files changed, 44 insertions, 44 deletions
diff --git a/src/dls.cpp b/src/dls.cpp index 006fc77..92c8da4 100644 --- a/src/dls.cpp +++ b/src/dls.cpp @@ -30,15 +30,15 @@ #include "dls.h" -// --- DLSManager ----------------------------------------------------------------- -const size_t DLSManager::MAXDLS = 128; // chars -const size_t DLSManager::DLS_SEG_LEN_PREFIX = 2; -const size_t DLSManager::DLS_SEG_LEN_CHAR_MAX = 16; -const std::string DLSManager::DL_PARAMS_OPEN = "##### parameters { #####"; -const std::string DLSManager::DL_PARAMS_CLOSE = "##### parameters } #####"; +// --- DLSEncoder ----------------------------------------------------------------- +const size_t DLSEncoder::MAXDLS = 128; // chars +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 } #####"; -DATA_GROUP* DLSManager::createDynamicLabelCommand(uint8_t command) { +DATA_GROUP* DLSEncoder::createDynamicLabelCommand(uint8_t command) { DATA_GROUP* dg = new DATA_GROUP(2, 2, 3); uint8_vector_t &seg_data = dg->data; @@ -59,7 +59,7 @@ DATA_GROUP* DLSManager::createDynamicLabelCommand(uint8_t command) { return dg; } -DATA_GROUP* DLSManager::createDynamicLabelPlus(const DL_STATE& dl_state) { +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); @@ -99,7 +99,7 @@ DATA_GROUP* DLSManager::createDynamicLabelPlus(const DL_STATE& dl_state) { } -bool DLSManager::parse_dl_param_bool(const std::string &key, const std::string &value, bool &target) { +bool DLSEncoder::parse_dl_param_bool(const std::string &key, const std::string &value, bool &target) { if (value == "0") { target = 0; return true; @@ -112,7 +112,7 @@ bool DLSManager::parse_dl_param_bool(const std::string &key, const std::string & return false; } -bool DLSManager::parse_dl_param_int_dl_plus_tag(const std::string &key, const std::string &value, int &target) { +bool DLSEncoder::parse_dl_param_int_dl_plus_tag(const std::string &key, const std::string &value, int &target) { int value_int = atoi(value.c_str()); if (value_int >= 0x00 && value_int <= 0x7F) { target = value_int; @@ -122,7 +122,7 @@ bool DLSManager::parse_dl_param_int_dl_plus_tag(const std::string &key, const st return false; } -void DLSManager::parse_dl_params(std::ifstream &dls_fstream, DL_STATE &dl_state) { +void DLSEncoder::parse_dl_params(std::ifstream &dls_fstream, DL_STATE &dl_state) { std::string line; while (std::getline(dls_fstream, line)) { // return on params close @@ -185,7 +185,7 @@ void DLSManager::parse_dl_params(std::ifstream &dls_fstream, DL_STATE &dl_state) } -void DLSManager::writeDLS(const std::string& dls_file, const DL_PARAMS& dl_params) { +void DLSEncoder::encodeLabel(const std::string& dls_file, const DL_PARAMS& dl_params) { DL_STATE dl_state; std::vector<std::string> dls_lines; @@ -278,13 +278,13 @@ void DLSManager::writeDLS(const std::string& dls_file, const DL_PARAMS& dl_param } -int DLSManager::dls_count(const std::string& text) { +int DLSEncoder::dls_count(const std::string& text) { size_t text_len = text.size(); return text_len / DLS_SEG_LEN_CHAR_MAX + (text_len % DLS_SEG_LEN_CHAR_MAX ? 1 : 0); } -DATA_GROUP* DLSManager::dls_get(const std::string& text, DABCharset charset, int seg_index) { +DATA_GROUP* DLSEncoder::dls_get(const std::string& text, DABCharset charset, int seg_index) { bool first_seg = seg_index == 0; bool last_seg = seg_index == dls_count(text) - 1; @@ -321,7 +321,7 @@ DATA_GROUP* DLSManager::dls_get(const std::string& text, DABCharset charset, int } -void DLSManager::prepend_dl_dgs(const DL_STATE& dl_state, DABCharset charset) { +void DLSEncoder::prepend_dl_dgs(const DL_STATE& dl_state, DABCharset charset) { // process all DL segments int seg_count = dls_count(dl_state.dl_text); std::vector<DATA_GROUP*> segs; @@ -126,8 +126,8 @@ struct DL_STATE { }; -// --- DLSManager ----------------------------------------------------------------- -class DLSManager { +// --- DLSEncoder ----------------------------------------------------------------- +class DLSEncoder { private: static const size_t MAXDLS; static const size_t DLS_SEG_LEN_PREFIX; @@ -149,8 +149,8 @@ private: bool dls_toggle; DL_STATE dl_state_prev; public: - DLSManager(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), dls_toggle(false) {} - void writeDLS(const std::string& dls_file, const DL_PARAMS& dl_params); + DLSEncoder(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), dls_toggle(false) {} + void encodeLabel(const std::string& dls_file, const DL_PARAMS& dl_params); }; #endif /* DLS_H_ */ diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 01385d0..c600320 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -296,8 +296,8 @@ const int BurstPadEncoder::DLS_REPETITION_WHILE_SLS = 50; // PADs int BurstPadEncoder::Encode() { PADPacketizer pad_packetizer(options.padlen); - DLSManager dls_manager(&pad_packetizer); - SLSManager sls_manager(&pad_packetizer); + DLSEncoder dls_encoder(&pad_packetizer); + SLSEncoder sls_encoder(&pad_packetizer); SlideStore slides; std::chrono::steady_clock::time_point next_run = std::chrono::steady_clock::now(); @@ -314,7 +314,7 @@ int BurstPadEncoder::Encode() { if (!slides.Empty()) { slide_metadata_t slide = slides.GetSlide(); - if (!sls_manager.encodeFile(slide.filepath, slide.fidx, options.raw_slides)) + if (!sls_encoder.encodeSlide(slide.filepath, slide.fidx, options.raw_slides)) fprintf(stderr, "ODR-PadEnc Error: cannot encode file '%s'\n", slide.filepath.c_str()); if (options.erase_after_tx) { @@ -325,7 +325,7 @@ int BurstPadEncoder::Encode() { // while flushing, insert DLS (if present) after a certain PAD amout while (pad_packetizer.QueueFilled()) { if (not options.dls_files.empty()) - dls_manager.writeDLS(options.dls_files[curr_dls_file], options.dl_params); + dls_encoder.encodeLabel(options.dls_files[curr_dls_file], options.dl_params); pad_packetizer.WriteAllPADs(output_fd, DLS_REPETITION_WHILE_SLS); } @@ -333,7 +333,7 @@ int BurstPadEncoder::Encode() { // encode (a last) DLS (if present) if (not options.dls_files.empty()) { - dls_manager.writeDLS(options.dls_files[curr_dls_file], options.dl_params); + dls_encoder.encodeLabel(options.dls_files[curr_dls_file], options.dl_params); // switch to next DLS file curr_dls_file = (curr_dls_file + 1) % options.dls_files.size(); diff --git a/src/sls.cpp b/src/sls.cpp index f059114..a401bad 100644 --- a/src/sls.cpp +++ b/src/sls.cpp @@ -108,7 +108,7 @@ int SlideStore::FilterSlides(const struct dirent* file) { return 0; // skip slide params files - if(SLSManager::isSlideParamFileFilename(name)) + if(SLSEncoder::isSlideParamFileFilename(name)) return 0; return 1; @@ -250,14 +250,14 @@ void MOTHeader::AddExtension(int param_id, const uint8_t* data_field, size_t dat } -// --- SLSManager ----------------------------------------------------------------- -const size_t SLSManager::MAXSEGLEN = 8189; // Bytes (EN 301 234 v2.1.1, ch. 5.1.1) -const size_t SLSManager::MAXSLIDESIZE = 51200; // Bytes (TS 101 499 v3.1.1, ch. 9.1.2) -const int SLSManager::MINQUALITY = 40; // Do not allow the image compressor to go below JPEG quality 40 -const std::string SLSManager::SLS_PARAMS_SUFFIX = ".sls_params"; +// --- SLSEncoder ----------------------------------------------------------------- +const size_t SLSEncoder::MAXSEGLEN = 8189; // Bytes (EN 301 234 v2.1.1, ch. 5.1.1) +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"; -void SLSManager::warnOnSmallerImage(size_t height, size_t width, const std::string& fname) { +void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname) { if (height < 240 || width < 320) fprintf(stderr, "ODR-PadEnc Warning: Image '%s' smaller than recommended size (%zu x %zu < 320 x 240 px)\n", fname.c_str(), width, height); } @@ -271,7 +271,7 @@ void SLSManager::warnOnSmallerImage(size_t height, size_t width, const std::stri * \return the blobsize */ #if HAVE_MAGICKWAND -size_t SLSManager::resizeImage(MagickWand* m_wand, unsigned char** blob, const std::string& fname, bool* jfif_not_png) +size_t SLSEncoder::resizeImage(MagickWand* m_wand, unsigned char** blob, const std::string& fname, bool* jfif_not_png) { unsigned char* blob_png; unsigned char* blob_jpg; @@ -350,7 +350,7 @@ size_t SLSManager::resizeImage(MagickWand* m_wand, unsigned char** blob, const s #endif -bool SLSManager::encodeFile(const std::string& fname, int fidx, bool raw_slides) +bool SLSEncoder::encodeSlide(const std::string& fname, int fidx, bool raw_slides) { bool result = false; @@ -586,7 +586,7 @@ encodefile_out: } -bool SLSManager::parse_sls_param_id(const std::string &key, const std::string &value, uint8_t &target) { +bool SLSEncoder::parse_sls_param_id(const std::string &key, const std::string &value, uint8_t &target) { int value_int = atoi(value.c_str()); if (value_int >= 0x00 && value_int <= 0xFF) { target = value_int; @@ -597,7 +597,7 @@ bool SLSManager::parse_sls_param_id(const std::string &key, const std::string &v } -bool SLSManager::check_sls_param_len(const std::string &key, size_t len, size_t len_max) { +bool SLSEncoder::check_sls_param_len(const std::string &key, size_t len, size_t len_max) { if (len <= len_max) return true; fprintf(stderr, "ODR-PadEnc Warning: SLS parameter '%s' exceeds its maximum length (%zu > %zu) - ignored\n", key.c_str(), len, len_max); @@ -605,7 +605,7 @@ bool SLSManager::check_sls_param_len(const std::string &key, size_t len, size_t } -void SLSManager::process_mot_params_file(MOTHeader& header, const std::string ¶ms_fname) { +void SLSEncoder::process_mot_params_file(MOTHeader& header, const std::string ¶ms_fname) { std::ifstream params_fstream(params_fname); if (!params_fstream.is_open()) return; @@ -678,7 +678,7 @@ void SLSManager::process_mot_params_file(MOTHeader& header, const std::string &p } -uint8_vector_t SLSManager::createMotHeader(size_t blobsize, int fidx, bool jfif_not_png, const std::string ¶ms_fname) +uint8_vector_t SLSEncoder::createMotHeader(size_t blobsize, int fidx, bool jfif_not_png, const std::string ¶ms_fname) { // prepare ContentName uint8_t cntemp[10]; // = 1 + 8 + 1 = charset + name + terminator @@ -705,7 +705,7 @@ uint8_vector_t SLSManager::createMotHeader(size_t blobsize, int fidx, bool jfif_ } -void SLSManager::createMscDG(MSCDG* msc, unsigned short int dgtype, +void SLSEncoder::createMscDG(MSCDG* msc, unsigned short int dgtype, int *cindex, unsigned short int segnum, unsigned short int lastseg, unsigned short int tid, unsigned char* data, unsigned short int datalen) @@ -731,7 +731,7 @@ void SLSManager::createMscDG(MSCDG* msc, unsigned short int dgtype, } -DATA_GROUP* SLSManager::packMscDG(MSCDG* msc) +DATA_GROUP* SLSEncoder::packMscDG(MSCDG* msc) { DATA_GROUP* dg = new DATA_GROUP(9 + msc->seglen, 12, 13); uint8_vector_t &b = dg->data; @@ -759,7 +759,7 @@ DATA_GROUP* SLSManager::packMscDG(MSCDG* msc) return dg; } -bool SLSManager::isSlideParamFileFilename(const std::string& filename) { +bool SLSEncoder::isSlideParamFileFilename(const std::string& filename) { return filename.length() >= SLS_PARAMS_SUFFIX.length() && filename.substr(filename.length() - SLS_PARAMS_SUFFIX.length()) == SLS_PARAMS_SUFFIX; } @@ -219,8 +219,8 @@ public: }; -// --- SLSManager ----------------------------------------------------------------- -class SLSManager { +// --- SLSEncoder ----------------------------------------------------------------- +class SLSEncoder { private: static const size_t MAXSEGLEN; static const size_t MAXSLIDESIZE; @@ -245,9 +245,9 @@ private: int cindex_header; int cindex_body; public: - SLSManager(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), cindex_header(0), cindex_body(0) {} + SLSEncoder(PADPacketizer* pad_packetizer) : pad_packetizer(pad_packetizer), cindex_header(0), cindex_body(0) {} - bool encodeFile(const std::string& fname, int fidx, bool raw_slides); + bool encodeSlide(const std::string& fname, int fidx, bool raw_slides); static bool isSlideParamFileFilename(const std::string& filename); }; |