Revision 403c545d libavformat/avc.c

View differences:

libavformat/avc.c
23 23
#include "avformat.h"
24 24
#include "avio.h"
25 25

  
26
const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end)
26
static const uint8_t *ff_avc_find_startcode_internal(const uint8_t *p, const uint8_t *end)
27 27
{
28 28
    const uint8_t *a = p + 4 - ((intptr_t)p & 3);
29 29

  
......
39 39
        if ((x - 0x01010101) & (~x) & 0x80808080) { // generic
40 40
            if (p[1] == 0) {
41 41
                if (p[0] == 0 && p[2] == 1)
42
                    return p-1;
43
                if (p[2] == 0 && p[3] == 1)
44 42
                    return p;
43
                if (p[2] == 0 && p[3] == 1)
44
                    return p+1;
45 45
            }
46 46
            if (p[3] == 0) {
47 47
                if (p[2] == 0 && p[4] == 1)
48
                    return p+1;
49
                if (p[4] == 0 && p[5] == 1)
50 48
                    return p+2;
49
                if (p[4] == 0 && p[5] == 1)
50
                    return p+3;
51 51
            }
52 52
        }
53 53
    }
......
60 60
    return end + 3;
61 61
}
62 62

  
63
const uint8_t *ff_avc_find_startcode(const uint8_t *p, const uint8_t *end){
64
    const uint8_t *out= ff_avc_find_startcode_internal(p, end);
65
    if(p<out && out<end && !out[-1]) out--;
66
    return out;
67
}
68

  
63 69
int ff_avc_parse_nal_units(ByteIOContext *pb, const uint8_t *buf_in, int size)
64 70
{
65 71
    const uint8_t *p = buf_in;

Also available in: Unified diff