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

Commit 89eb0c7b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix AC-4 parser bugs according to specification"

parents e229cd12 4d6916a5
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -295,6 +295,7 @@ bool AC4DSIParser::parse() {
        bool b_single_substream_group = false;
        uint32_t presentation_config = 0, presentation_version = 0;
        uint32_t pres_bytes = 0;
        uint64_t start = 0;

        if (ac4_dsi_version == 0) {
            CHECK_BITS_LEFT(1 + 5 + 5);
@@ -315,6 +316,8 @@ bool AC4DSIParser::parse() {
                mBitReader.skipBits(pres_bytes * 8);
                continue;
            }
            /* record a marker, less the size of the presentation_config */
            start = (mDSISize - mBitReader.numBitsLeft()) / 8;
            // ac4_presentation_v0_dsi(), ac4_presentation_v1_dsi() and ac4_presentation_v2_dsi()
            // all start with a presentation_config of 5 bits
            CHECK_BITS_LEFT(5);
@@ -338,9 +341,6 @@ bool AC4DSIParser::parse() {
            (presentation_config >= NELEM(PresentationConfig) ?
            "reserved" : PresentationConfig[presentation_config]));

        /* record a marker, less the size of the presentation_config */
        uint64_t start = (mDSISize - mBitReader.numBitsLeft()) / 8;

        bool b_add_emdf_substreams = false;
        if (!b_single_substream_group && presentation_config == 6) {
            b_add_emdf_substreams = true;
@@ -535,6 +535,7 @@ bool AC4DSIParser::parse() {
                    }
                    break;
                }
            }
            CHECK_BITS_LEFT(1 + 1);
            bool b_pre_virtualized = (mBitReader.getBits(1) == 1);
            mPresentations[presentation].mPreVirtualized = b_pre_virtualized;
@@ -543,7 +544,6 @@ bool AC4DSIParser::parse() {
            ALOGV("%u: b_add_emdf_substreams = %s\n", presentation,
                BOOLSTR(b_add_emdf_substreams));
        }
        }
        if (b_add_emdf_substreams) {
            CHECK_BITS_LEFT(7);
            uint32_t n_add_emdf_substreams = mBitReader.getBits(7);
@@ -599,10 +599,6 @@ bool AC4DSIParser::parse() {

        if (ac4_dsi_version == 1) {
            uint64_t end = (mDSISize - mBitReader.numBitsLeft()) / 8;
            if (mBitReader.numBitsLeft() % 8 != 0) {
                end += 1;
            }

            uint64_t presentation_bytes = end - start;
            uint64_t skip_bytes = pres_bytes - presentation_bytes;
            ALOGV("skipping = %" PRIu64 " bytes", skip_bytes);