diff options
author | Stefan Pöschel <github@basicmaster.de> | 2015-04-18 19:29:47 +0200 |
---|---|---|
committer | Stefan Pöschel <github@basicmaster.de> | 2015-04-18 19:29:47 +0200 |
commit | 5c6b9fb58d66b01c660798d33c3e7704dada49e6 (patch) | |
tree | 99a64ae35d1a6e7928bd21cd156a02ad13ce7dbf | |
parent | 299beb774b0294bb1444d9436f893173aa075751 (diff) | |
download | ODR-AudioEnc-5c6b9fb58d66b01c660798d33c3e7704dada49e6.tar.gz ODR-AudioEnc-5c6b9fb58d66b01c660798d33c3e7704dada49e6.tar.bz2 ODR-AudioEnc-5c6b9fb58d66b01c660798d33c3e7704dada49e6.zip |
MOT encoder protocol change: transmit used PAD bytes
-rw-r--r-- | src/dabplus-enc.cpp | 8 | ||||
-rw-r--r-- | src/mot-encoder.cpp | 13 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp index 7ab23d1..a91e4c9 100644 --- a/src/dabplus-enc.cpp +++ b/src/dabplus-enc.cpp @@ -624,7 +624,7 @@ int main(int argc, char *argv[]) uint8_t outbuf[24*120]; - unsigned char pad_buf[padlen]; + unsigned char pad_buf[padlen + 1]; if(outbuf_size % 5 != 0) { fprintf(stderr, "(outbuf_size mod 5) = %d\n", outbuf_size % 5); @@ -683,7 +683,7 @@ int main(int argc, char *argv[]) // --------------- Read data from the PAD fifo int ret; if (padlen != 0) { - ret = read(pad_fd, pad_buf, padlen); + ret = read(pad_fd, pad_buf, padlen + 1); } else { ret = 0; @@ -802,11 +802,11 @@ int main(int argc, char *argv[]) // -------------- AAC Encoding - int calculated_padlen = ret > 0 ? padlen : 0; + int calculated_padlen = ret > 0 ? pad_buf[padlen] : 0; in_ptr[0] = input_buf; - in_ptr[1] = pad_buf; + in_ptr[1] = pad_buf + (padlen - calculated_padlen); // offset due to unused PAD bytes in_size[0] = read; in_size[1] = calculated_padlen; in_elem_size[0] = BYTES_PER_SAMPLE; diff --git a/src/mot-encoder.cpp b/src/mot-encoder.cpp index f84326e..8422514 100644 --- a/src/mot-encoder.cpp +++ b/src/mot-encoder.cpp @@ -241,6 +241,7 @@ static int cindex_body = 0; // DLS related +#define FPAD_LEN 2 #define DLS_SEG_LEN_PREFIX 2 #define DLS_SEG_LEN_CHAR_MAX 16 #define DLS_SEG_LEN_CRC 2 @@ -1009,7 +1010,7 @@ void create_dls_pads(const char* text, const int padlen, const uint8_t charset) // distribute the segment over one or more PADs for (int seg_off = 0; seg_off < seg_len;) { - dls_pads.push_back(pad_t(padlen)); + dls_pads.push_back(pad_t(padlen + 1)); pad_t &pad = dls_pads.back(); int pad_off = padlen - 1; @@ -1048,6 +1049,9 @@ void create_dls_pads(const char* text, const int padlen, const uint8_t charset) // NULL PADDING std::fill_n(pad.begin(), pad_off + 1, 0x00); + // set used pad len + pad[padlen] = FPAD_LEN + used_xpad_len; + #if DEBUG fprintf(stderr, "DLS data group:"); for (int i = 0; i < padlen; i++) @@ -1071,7 +1075,7 @@ void writeMotPAD(int output_fd, unsigned short int padlen) { - unsigned char pad[padlen]; + unsigned char pad[padlen + 1]; int xpadlengthmask, i, j, k; unsigned short int crc; @@ -1145,7 +1149,10 @@ void writeMotPAD(int output_fd, pad[j] = 0x00; } - size_t dummy = write(output_fd, pad, padlen); + // set used pad len + pad[padlen] = FPAD_LEN + used_xpad_len; + + size_t dummy = write(output_fd, pad, padlen + 1); #if DEBUG fprintf(stderr,"MSC Data Group - Segment %d: ",i); for (j=0;j<padlen;j++) |