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

Commit 25bad49c authored by Wei Jia's avatar Wei Jia Committed by Android Git Automerger
Browse files

am 852dc963: Merge "avc_util: try to find the first start code prefix 0x000001...

am 852dc963: Merge "avc_util: try to find the first start code prefix 0x000001 even though there is non-zero byte at the beginning of the buffer." into lmp-mr1-dev

* commit '852dc963':
  avc_util: try to find the first start code prefix 0x000001 even though there is non-zero byte at the beginning of the buffer.
parents 561f50de 852dc963
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -222,28 +222,25 @@ status_t getNextNALUnit(
    *nalStart = NULL;
    *nalSize = 0;

    if (size == 0) {
    if (size < 3) {
        return -EAGAIN;
    }

    // Skip any number of leading 0x00.

    size_t offset = 0;
    while (offset < size && data[offset] == 0x00) {
        ++offset;
    }

    if (offset == size) {
        return -EAGAIN;
    }

    // A valid startcode consists of at least two 0x00 bytes followed by 0x01.

    if (offset < 2 || data[offset] != 0x01) {
        return ERROR_MALFORMED;
    for (; offset + 2 < size; ++offset) {
        if (data[offset + 2] == 0x01 && data[offset] == 0x00
                && data[offset + 1] == 0x00) {
            break;
        }

    ++offset;
    }
    if (offset + 2 >= size) {
        *_data = &data[offset];
        *_size = 2;
        return -EAGAIN;
    }
    offset += 3;

    size_t startOffset = offset;

+3 −2
Original line number Diff line number Diff line
@@ -346,12 +346,13 @@ status_t ElementaryStreamQueue::appendData(
                }

                if (frameLength != size - startOffset) {
                    ALOGW("got ADTS AAC frame length %zd instead of %zd",
                    ALOGW("First ADTS AAC frame length is %zd bytes, "
                          "while the buffer size is %zd bytes.",
                          frameLength, size - startOffset);
                }

                data = &ptr[startOffset];
                size = frameLength;
                size -= startOffset;
#endif
                break;
            }