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

Commit 8e3db8fc authored by Marco Nelissen's avatar Marco Nelissen Committed by Gerrit Code Review
Browse files

Merge "MatroskaExtractor: don't use new buffer unless necessary"

parents c5ea4edc ba29bb20
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -534,6 +534,7 @@ status_t MatroskaSource::readBlock() {
            mPendingFrames.clear();

            mBlockIter.advance();
            mbuf->release();
            return ERROR_IO;
        }

@@ -633,10 +634,12 @@ status_t MatroskaSource::read(
            if (pass == 1) {
                memcpy(&dstPtr[dstOffset], "\x00\x00\x00\x01", 4);

                if (frame != buffer) {
                    memcpy(&dstPtr[dstOffset + 4],
                           &srcPtr[srcOffset + mNALSizeLen],
                           NALsize);
                }
            }

            dstOffset += 4;  // 0x00 00 00 01
            dstOffset += NALsize;
@@ -657,7 +660,13 @@ status_t MatroskaSource::read(
        if (pass == 0) {
            dstSize = dstOffset;

            if (dstSize == srcSize && mNALSizeLen == 4) {
                // In this special case we can re-use the input buffer by substituting
                // each 4-byte nal size with a 4-byte start code
                buffer = frame;
            } else {
                buffer = new MediaBuffer(dstSize);
            }

            int64_t timeUs;
            CHECK(frame->meta_data()->findInt64(kKeyTime, &timeUs));
@@ -671,8 +680,10 @@ status_t MatroskaSource::read(
        }
    }

    if (frame != buffer) {
        frame->release();
        frame = NULL;
    }

    if (targetSampleTimeUs >= 0ll) {
        buffer->meta_data()->setInt64(