diff --git a/pvr.hts/addon.xml.in b/pvr.hts/addon.xml.in index 73092dce..bbcc4fe4 100644 --- a/pvr.hts/addon.xml.in +++ b/pvr.hts/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.hts/changelog.txt b/pvr.hts/changelog.txt index b7b19185..63c2ec1d 100644 --- a/pvr.hts/changelog.txt +++ b/pvr.hts/changelog.txt @@ -1,10 +1,9 @@ +v19.0.1 +- Fix AAC RDS parser + v19.0.0 - Translations updates from Weblate - - ko_kr -- Changed test builds to 'Kodi 19 Matrix' -- Increased version to 19.0.0 - - With start of Kodi 20 Nexus, takes addon as major the same version number as Kodi. - This done to know easier to which Kodi the addon works. +- Version numbering scheme change. v8.4.0 - Add support for RDS data contained in AAC streams. diff --git a/src/aac/elements/DSE.cpp b/src/aac/elements/DSE.cpp index 98356481..56666bda 100644 --- a/src/aac/elements/DSE.cpp +++ b/src/aac/elements/DSE.cpp @@ -9,6 +9,7 @@ #include "../BitStream.h" +#include #include using namespace aac; @@ -43,42 +44,53 @@ uint8_t DSE::DecodeRDS(BitStream& stream, uint8_t*& rdsdata) if (byteAlign) stream.ByteAlign(); - if (count > 2) // we need at least 0xFE + some-other-byte + 0xFF + static constexpr int BUFFER_SIZE = 65536; + static uint8_t buffer[BUFFER_SIZE]; + static int bufferpos = 0; + + uint8_t ret = 0; + + if (count > BUFFER_SIZE) { - const uint8_t firstElem = static_cast(stream.ReadBits(8)); - if (firstElem == 0xFE) // could be RDS data start - { - rdsdata = new uint8_t[count]; - rdsdata[0] = firstElem; - - try - { - for (int i = 1; i < count; ++i) - rdsdata[i] = static_cast(stream.ReadBits(8)); - - if (rdsdata[count - 1] == 0xFF) // RDS data end - return count; // Note: caller has to delete the data array - } - catch (std::exception&) - { - // cleanup and rethrow - delete[] rdsdata; - rdsdata = nullptr; - throw; - } - - // data start with 0xFE, but do not end with 0xFF, thus no RDS data - delete[] rdsdata; - rdsdata = nullptr; - } - else + // data package too large! turn over with next package. + stream.SkipBits(8 * count); + bufferpos = 0; + return ret; + } + + if (bufferpos + count > BUFFER_SIZE) + { + // buffer overflow! turn over now. + bufferpos = 0; + } + + try + { + // collect data + for (int i = 0; i < count; ++i) { - stream.SkipBits(8 * (count - 1)); + buffer[bufferpos + i] = static_cast(stream.ReadBits(8)); } + bufferpos += count; } - else + catch (std::exception&) { - stream.SkipBits(8 * count); + // cleanup and rethrow + bufferpos = 0; + throw; } - return 0; + + if (bufferpos > 0 && buffer[bufferpos - 1] == 0xFF) + { + if (buffer[0] == 0xFE) + { + // data package is complete. deliver it. + rdsdata = new uint8_t[bufferpos]; // Note: caller has to delete the data array + std::memcpy(rdsdata, buffer, bufferpos); + ret = bufferpos; + } + bufferpos = 0; + } + + return ret; }