aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Pöschel <github@basicmaster.de>2015-04-10 15:59:36 +0200
committerStefan Pöschel <github@basicmaster.de>2015-04-10 15:59:36 +0200
commitac3fc4bdb8647e7707a58bb569a9b3a292a55209 (patch)
treecb0004f7622b3ba6e66ef412fc7b4cf07b96b2e3 /src
parent4ed8967e8b4b9fd108532f175295d953eb54b87b (diff)
downloadODR-PadEnc-ac3fc4bdb8647e7707a58bb569a9b3a292a55209.tar.gz
ODR-PadEnc-ac3fc4bdb8647e7707a58bb569a9b3a292a55209.tar.bz2
ODR-PadEnc-ac3fc4bdb8647e7707a58bb569a9b3a292a55209.zip
(Re)Create DLS data groups only if needed
Diffstat (limited to 'src')
-rw-r--r--src/mot-encoder.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/mot-encoder.cpp b/src/mot-encoder.cpp
index 2cd497f..0548614 100644
--- a/src/mot-encoder.cpp
+++ b/src/mot-encoder.cpp
@@ -229,8 +229,9 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset);
int get_xpadlengthmask(int padlen);
#define ALLOWED_PADLEN "23, 26, 34, 42, 58"
-// The toggle flag for the DLS
+// The toggle info for the DLS
static uint8_t dls_toggle = 0;
+char dlstext_prev[MAXDLS + 1];
// The DLS data groups
std::deque<std::vector<uint8_t> > dlsdg;
@@ -875,6 +876,7 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset)
char dlstext[MAXDLS + 1];
int dlslen;
int i;
+ bool dlstext_new;
if (dlsfd != 0) {
close(dlsfd);
@@ -899,11 +901,16 @@ void writeDLS(int output_fd, const char* dls_file, int padlen, uint8_t charset)
endp--;
}
+ // (Re)Create data groups (and thereby toggle the toggle bit) only on (first call or) new text
+ dlstext_new = dlsdg.empty() || strcmp(dlstext, dlstext_prev);
if (verbose) {
- fprintf(stderr, "mot-encoder writing DLS text \"%s\"\n", dlstext);
+ fprintf(stderr, "mot-encoder writing %s DLS text \"%s\"\n", dlstext_new ? "new" : "old", dlstext);
+ }
+ if (dlstext_new) {
+ create_dls_datagroup(dlstext, padlen, charset);
+ strcpy(dlstext_prev, dlstext);
}
- create_dls_datagroup(dlstext, padlen, charset);
for (i = 0; i < dlsdg.size(); i++) {
size_t dummy = write(output_fd, &dlsdg[i].front(), dlsdg[i].size());
}