summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/avc_utils.cpp
diff options
context:
space:
mode:
authorWei Jia <wjia@google.com>2014-12-05 02:44:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-12-05 02:44:17 +0000
commit852dc963a53487f2e2f197ab095299aed9c60a5e (patch)
tree8bb5fe9cb0061af9733cd41626bbafbc1d113872 /media/libstagefright/avc_utils.cpp
parentdb995fe3239276be9dfd9e446b10417e07948acc (diff)
parent15ebd70bdb7aeb3d5ce309710dbd64c0ea038113 (diff)
downloadframeworks_av-852dc963a53487f2e2f197ab095299aed9c60a5e.zip
frameworks_av-852dc963a53487f2e2f197ab095299aed9c60a5e.tar.gz
frameworks_av-852dc963a53487f2e2f197ab095299aed9c60a5e.tar.bz2
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
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;