summaryrefslogtreecommitdiff
path: root/libavformat/avc.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2010-02-22 00:34:27 +0000
committerMichael Niedermayer <michaelni@gmx.at>2010-02-22 00:34:27 +0000
commit403c545d08c8cfeb335f3ecb508ef90a54a44037 (patch)
treee6be908939a3157222aaef26281a821417c6e17d /libavformat/avc.c
parentdd4a03f7b3fa32d47ada88bc6e0a2af4dbc0cddf (diff)
downloadffmpeg-403c545d08c8cfeb335f3ecb508ef90a54a44037.tar.gz
Attempt to fix the completely random values returned by ff_avc_find_startcode().
Originally committed as revision 21955 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/avc.c')
-rw-r--r--libavformat/avc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libavformat/avc.c b/libavformat/avc.c
index 0731e39698..f2b57cd51a 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -23,7 +23,7 @@
#include "avformat.h"
#include "avio.h"
-const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)
+static const uint8_t *ff_avc_find_startcode_internal(const uint8_t *p, const uint8_t *end)
{
const uint8_t *a = p + 4 - ((intptr_t)p & 3);
@@ -39,15 +39,15 @@ const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)
if ((x - 0x01010101) & (~x) & 0x80808080) { // generic
if (p[1] == 0) {
if (p[0] == 0 && p[2] == 1)
- return p-1;
- if (p[2] == 0 && p[3] == 1)
return p;
+ if (p[2] == 0 && p[3] == 1)
+ return p+1;
}
if (p[3] == 0) {
if (p[2] == 0 && p[4] == 1)
- return p+1;
- if (p[4] == 0 && p[5] == 1)
return p+2;
+ if (p[4] == 0 && p[5] == 1)
+ return p+3;
}
}
}
@@ -60,6 +60,12 @@ const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)
return end + 3;
}
+const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end){
+ const uint8_t *out= ff_avc_find_startcode_internal(p, end);
+ if(p<out && out<end && !out[-1]) out--;
+ return out;
+}
+
int ff_avc_parse_nal_units(ByteIOContext *pb, const uint8_t *buf_in, int size)
{
const uint8_t *p = buf_in;