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

Commit 14bb6a3b authored by Lajos Molnar's avatar Lajos Molnar
Browse files

revert ARTPWriter StripStartcode fix

This is reverted so fixes to this code from AOSP can be applied.

Bug: 165061754
Merged-in: I41f5bb67049f4e4ff454aedac28b5cbda2c4df24
Change-Id: I41f5bb67049f4e4ff454aedac28b5cbda2c4df24
parent 6a104738
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -295,8 +295,8 @@ static uint32_t StripStartcode(MediaBufferBase *buffer) {

    ptr = (const uint8_t *)buffer->data() + buffer->range_offset();

    if (buffer->range_length() > 0 && (*ptr & H264_NALU_MASK) == H264_NALU_SPS) {
        for (uint32_t i = 1; i + 4 <= buffer->range_length(); i++) {
    if ((*ptr & H264_NALU_MASK) == H264_NALU_SPS) {
        for (uint32_t i = 0; i < buffer->range_length(); i++) {

            if (!memcmp(ptr + i, "\x00\x00\x00\x01", 4)) {
                // Now, we found one more NAL unit in the media buffer.
@@ -328,13 +328,13 @@ static void SpsPpsParser(MediaBufferBase *mediaBuffer,

    // we got sps/pps but startcode of sps is striped.
    (*spsBuffer) = MediaBufferBase::Create(spsSize);
    int32_t ppsSize = mediaBuffer->range_length() - spsSize - 4/*startcode*/;
    (*ppsBuffer) = MediaBufferBase::Create(ppsSize);
    memcpy((*spsBuffer)->data(),
            (const uint8_t *)mediaBuffer->data() + mediaBuffer->range_offset(),
            spsSize);

    int32_t ppsSize = mediaBuffer->range_length() - spsSize - 4 /*startcode*/;
    if (ppsSize > 0) {
        (*ppsBuffer) = MediaBufferBase::Create(ppsSize);
        ALOGV("PPS found. size=%d", (int)ppsSize);
        mediaBuffer->set_range(mediaBuffer->range_offset() + spsSize + 4/*startcode*/,
                mediaBuffer->range_length() - spsSize - 4/*startcode*/);