29 const uint8_t *
a = p + 4 - ((intptr_t)p & 3);
31 for (end -= 3; p < a && p <
end; p++) {
32 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
36 for (end -= 3; p <
end; p += 4) {
37 uint32_t x = *(
const uint32_t*)p;
40 if ((x - 0x01010101) & (~x) & 0x80808080) {
42 if (p[0] == 0 && p[2] == 1)
44 if (p[2] == 0 && p[3] == 1)
48 if (p[2] == 0 && p[4] == 1)
50 if (p[4] == 0 && p[5] == 1)
56 for (end += 3; p <
end; p++) {
57 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
66 if(p<out && out<end && !out[-1]) out--;
74 const uint8_t *nal_start, *nal_end;
79 while (nal_start < end && !*(nal_start++));
85 avio_write(pb, nal_start, nal_end - nal_start);
86 size += 4 + nal_end - nal_start;
110 if (
AV_RB32(data) == 0x00000001 ||
113 uint32_t sps_size=0, pps_size=0;
123 while (end - buf > 4) {
128 nal_type = buf[0] & 0x1f;
133 }
else if (nal_type == 8) {
141 if (!sps || !pps || sps_size < 4 || sps_size > UINT16_MAX || pps_size > UINT16_MAX)
166 uint16_t sps_size, pps_size;
171 if (*size >= 4 && (
AV_RB32(in) == 0x00000001 ||
AV_RB24(in) == 0x000001))
173 if (*size < 11 || in[0] != 1)
177 if (11 + sps_size > *size)
179 pps_size =
AV_RB16(&in[9 + sps_size]);
180 if (11 + sps_size + pps_size > *size)
182 out_size = 8 + sps_size + pps_size;
187 memcpy(out + 4, &in[8], sps_size);
188 AV_WB32(&out[4 + sps_size], 0x00000001);
189 memcpy(out + 8 + sps_size, &in[11 + sps_size], pps_size);
199 unsigned int res = 0;
201 if (end - start < nal_length_size)
203 while (nal_length_size--)
204 res = (res << 8) | *start++;
206 if (res > end - start)