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

Commit 28c7c2e5 authored by Marco Nelissen's avatar Marco Nelissen Committed by android-build-merger
Browse files

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

am: 8e3db8fc

* commit '8e3db8fc':
  MatroskaExtractor: don't use new buffer unless necessary
parents c24b47c3 8e3db8fc
Loading
Loading
Loading
Loading
+17 −6
Original line number Original line Diff line number Diff line
@@ -534,6 +534,7 @@ status_t MatroskaSource::readBlock() {
            mPendingFrames.clear();
            mPendingFrames.clear();


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


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


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


            dstOffset += 4;  // 0x00 00 00 01
            dstOffset += 4;  // 0x00 00 00 01
            dstOffset += NALsize;
            dstOffset += NALsize;
@@ -657,7 +660,13 @@ status_t MatroskaSource::read(
        if (pass == 0) {
        if (pass == 0) {
            dstSize = dstOffset;
            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);
                buffer = new MediaBuffer(dstSize);
            }


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


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


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