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

Commit 15ebd70b authored by Wei Jia's avatar Wei Jia
Browse files

avc_util: try to find the first start code prefix 0x000001 even though there...

avc_util: try to find the first start code prefix 0x000001 even though there is non-zero byte at the beginning of the buffer.

ESQueue: allow one PES playload contains multiple ADTS AAC frames.

Bug: 18532335
Change-Id: I1f42017cff139d5e932e0aaa3e7d33164d1a48e7
parent 814cbb4e
Loading
Loading
Loading
Loading
+12 −15
Original line number Original line Diff line number Diff line
@@ -222,28 +222,25 @@ status_t getNextNALUnit(
    *nalStart = NULL;
    *nalStart = NULL;
    *nalSize = 0;
    *nalSize = 0;


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


    // Skip any number of leading 0x00.

    size_t offset = 0;
    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.
    // A valid startcode consists of at least two 0x00 bytes followed by 0x01.

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

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


    size_t startOffset = offset;
    size_t startOffset = offset;


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


                if (frameLength != size - startOffset) {
                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);
                          frameLength, size - startOffset);
                }
                }


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