summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/avc_utils.cpp
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2014-12-05 02:53:21 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-12-05 02:53:21 +0000
commit25bad49ce75758b2f68b278f54d7272b1cf4d08c (patch)
tree8bb5fe9cb0061af9733cd41626bbafbc1d113872 /media/libstagefright/avc_utils.cpp
parent561f50de82ce47f11ba8d4f25db1ca1d8467b2a7 (diff)
parent852dc963a53487f2e2f197ab095299aed9c60a5e (diff)
downloadframeworks_av-25bad49ce75758b2f68b278f54d7272b1cf4d08c.zip
frameworks_av-25bad49ce75758b2f68b278f54d7272b1cf4d08c.tar.gz
frameworks_av-25bad49ce75758b2f68b278f54d7272b1cf4d08c.tar.bz2
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 '852dc963a53487f2e2f197ab095299aed9c60a5e': 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/avc_utils.cpp')
-rw-r--r--media/libstagefright/avc_utils.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp
index 38a1f6b..cbdb816 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;