Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f8a9dd4 authored by Lucas Gates's avatar Lucas Gates
Browse files

TunerHAL Fix bug in TS Size Read

Previously in CL 19152256 the size variables for Pes and
Section event reading were made unsigned in order to
prevent negative values. However, the conversion from
int8_t directly to uint32_t still produces incorrect values.
To solve this, the values which are read in are first
converted from int8_t to uint8_t before their final
conversion.

Bug: 238797416
Test: Run on Cuttlefish with TS input, and view logging.
Old version should not work with any TS that declares a
size containing any byte with value > 0x80.

Change-Id: I55bb552bc857fd8acf16729f8cfcb9e147e07e9c
parent 2781deca
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -793,7 +793,8 @@ void Filter::updateRecordOutput(vector<int8_t>& data) {
            }
            if (prefix == 0x000001) {
                // TODO handle mulptiple Pes filters
                mPesSizeLeft = (mFilterOutput[i + 8] << 8) | mFilterOutput[i + 9];
                mPesSizeLeft = (static_cast<uint8_t>(mFilterOutput[i + 8]) << 8) |
                               static_cast<uint8_t>(mFilterOutput[i + 9]);
                mPesSizeLeft += 6;
                if (DEBUG_FILTER) {
                    ALOGD("[Filter] pes data length %d", mPesSizeLeft);
@@ -875,7 +876,8 @@ void Filter::updateRecordOutput(vector<int8_t>& data) {
            }
            if (prefix == 0x000001) {
                // TODO handle mulptiple Pes filters
                mPesSizeLeft = (mFilterOutput[i + 8] << 8) | mFilterOutput[i + 9];
                mPesSizeLeft = (static_cast<uint8_t>(mFilterOutput[i + 8]) << 8) |
                               static_cast<uint8_t>(mFilterOutput[i + 9]);
                mPesSizeLeft += 6;
                if (DEBUG_FILTER) {
                    ALOGD("[Filter] pes data length %d", mPesSizeLeft);
@@ -973,7 +975,8 @@ bool Filter::writeSectionsAndCreateEvent(vector<int8_t>& data) {
        if (mSectionSizeLeft == 0) {
            // Location for sectionSize as defined by Section 2.4.4
            // Note that the first 4 bytes skipped are the TsHeader
            mSectionSizeLeft = ((data[i + 5] & 0x0f) << 8) | (data[i + 6] & 0xff);
            mSectionSizeLeft = ((static_cast<uint8_t>(data[i + 5]) & 0x0f) << 8) |
                               static_cast<uint8_t>(data[i + 6]);
            mSectionSizeLeft += 3;
            if (DEBUG_FILTER) {
                ALOGD("[Filter] section data length %d", mSectionSizeLeft);