diff options
author | Wei Jia <wjia@google.com> | 2014-12-08 19:13:57 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-12-08 19:13:57 +0000 |
commit | 5185c95673f7c6facd6d57fdc9fc53f52e44eed8 (patch) | |
tree | fe54124c4b16e941d3632ebe3b72899ff148262a /media/libstagefright | |
parent | 900f6535af232298e4a77477907a40f68e8dc61b (diff) | |
parent | 25bad49ce75758b2f68b278f54d7272b1cf4d08c (diff) | |
download | frameworks_av-5185c95673f7c6facd6d57fdc9fc53f52e44eed8.zip frameworks_av-5185c95673f7c6facd6d57fdc9fc53f52e44eed8.tar.gz frameworks_av-5185c95673f7c6facd6d57fdc9fc53f52e44eed8.tar.bz2 |
am 25bad49c: 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 '25bad49ce75758b2f68b278f54d7272b1cf4d08c':
avc_util: try to find the first start code prefix 0x000001 even though there is non-zero byte at the beginning of the buffer.
Diffstat (limited to 'media/libstagefright')
-rw-r--r-- | media/libstagefright/avc_utils.cpp | 27 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/ESQueue.cpp | 5 |
2 files changed, 15 insertions, 17 deletions
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp index fc03607..5ec3438 100644 --- a/media/libstagefright/avc_utils.cpp +++ b/media/libstagefright/avc_utils.cpp @@ -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; diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp index 6662569..73fe109 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.cpp +++ b/media/libstagefright/mpeg2ts/ESQueue.cpp @@ -343,12 +343,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; } |