summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Pöschel <github@basicmaster.de>2015-04-18 19:11:58 +0200
committerStefan Pöschel <github@basicmaster.de>2015-04-18 19:11:58 +0200
commit299beb774b0294bb1444d9436f893173aa075751 (patch)
treeb8f657de2b7a76f855ded564c4fca68bf6207e02
parent90518e0ca2386a98b7e6950567dc8816dd455126 (diff)
downloadfdk-aac-dabplus-299beb774b0294bb1444d9436f893173aa075751.tar.gz
fdk-aac-dabplus-299beb774b0294bb1444d9436f893173aa075751.tar.bz2
fdk-aac-dabplus-299beb774b0294bb1444d9436f893173aa075751.zip
Fix len of used X-PAD at DLS
With the currently allowed PAD lengths, this did not lead to a problem, but this change avoids problems in the future.
-rw-r--r--src/mot-encoder.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/mot-encoder.cpp b/src/mot-encoder.cpp
index bc5b736..f84326e 100644
--- a/src/mot-encoder.cpp
+++ b/src/mot-encoder.cpp
@@ -1004,6 +1004,8 @@ void create_dls_pads(const char* text, const int padlen, const uint8_t charset)
fprintf(stderr, "Segment number %d\n", seg_index + 1);
#endif
int seg_len = dls_get(text, charset, seg_index, seg_data);
+ int dg_len;
+ int used_xpad_len;
// distribute the segment over one or more PADs
for (int seg_off = 0; seg_off < seg_len;) {
@@ -1014,7 +1016,14 @@ void create_dls_pads(const char* text, const int padlen, const uint8_t charset)
bool var_size_pad = padlen != SHORT_PAD;
bool ci_needed = seg_off == 0; // CI needed only at first data group
- int dg_len = ci_needed ? get_xpadlength(xpadlengthmask) : padlen - 2;
+ if (ci_needed) {
+ dg_len = get_xpadlength(xpadlengthmask);
+
+ // variable size X-PAD: size of first X-PAD = DLS-DG + End of CI list + CI = size of subsequent non-CI X-PADs
+ used_xpad_len = var_size_pad ? dg_len + 1 + 1 : padlen - 2;
+ } else {
+ dg_len = used_xpad_len;
+ }
int dg_used = MIN(dg_len, seg_len - seg_off);
@@ -1069,7 +1078,7 @@ void writeMotPAD(int output_fd,
xpadlengthmask = get_xpadlengthmask(padlen);
// Write MSC Data Groups
- int curseglen, non_ci_seglen;
+ int curseglen, used_xpad_len;
for (i = 0; i < mscdgsize; i += curseglen) {
uint8_t* curseg;
uint8_t firstseg;
@@ -1084,11 +1093,11 @@ void writeMotPAD(int output_fd,
curseglen = get_xpadlength(xpadlengthmask);
// size of first X-PAD = MSC-DG + DGLI-DG + End of CI list + 2x CI = size of subsequent non-CI X-PADs
- non_ci_seglen = curseglen + 4 + 1 + 2;
+ used_xpad_len = curseglen + 4 + 1 + 2;
}
else {
firstseg = 0;
- curseglen = non_ci_seglen;
+ curseglen = used_xpad_len;
}
curseglen = MIN(curseglen, mscdgsize - i);