32 const uint8_t *
a = p + 4 - ((intptr_t)p & 3);
34 for (end -= 3; p <
a && p < end; p++) {
35 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
39 for (end -= 3; p < end; p += 4) {
40 uint32_t x = *(
const uint32_t*)p;
43 if ((x - 0x01010101) & (~x) & 0x80808080) {
45 if (p[0] == 0 && p[2] == 1)
47 if (p[2] == 0 && p[3] == 1)
51 if (p[2] == 0 && p[4] == 1)
53 if (p[4] == 0 && p[5] == 1)
59 for (end += 3; p < end; p++) {
60 if (p[0] == 0 && p[1] == 0 && p[2] == 1)
75 const uint8_t *p = buf_in;
76 const uint8_t *end = p +
size;
77 const uint8_t *nal_start, *nal_end;
82 while (nal_start < end && !*(nal_start++));
88 avio_write(pb, nal_start, nal_end - nal_start);
89 size += 4 + nal_end - nal_start;
111 uint8_t *buf, *end, *start;
112 uint8_t *
sps, *
pps, *sps_ext;
113 uint32_t sps_size = 0, pps_size = 0, sps_ext_size = 0;
114 int ret, nb_sps = 0, nb_pps = 0, nb_sps_ext = 0;
143 while (end - buf > 4) {
148 nal_type = buf[0] & 0x1f;
158 }
else if (nal_type == 8) {
166 }
else if (nal_type == 13) {
168 if (
size > UINT16_MAX || nb_sps_ext >= 256) {
182 if (sps_size < 6 || !pps_size) {
198 if (
sps[3] != 66 &&
sps[3] != 77 &&
sps[3] != 88) {
223 uint16_t sps_size, pps_size;
230 if (*
size < 11 || in[0] != 1)
234 if (11 + sps_size > *
size)
236 pps_size =
AV_RB16(&in[9 + sps_size]);
237 if (11 + sps_size + pps_size > *
size)
244 memcpy(
out + 4, &in[8], sps_size);
246 memcpy(
out + 8 + sps_size, &in[11 + sps_size], pps_size);
256 unsigned int res = 0;
258 if (end - start < nal_length_size)
260 while (nal_length_size--)
261 res = (res << 8) | *start++;
263 if (res > end - start)
270 uint32_t *dst_len,
int header_len)
281 while (
i < header_len &&
i < src_len)
284 while (
i + 2 < src_len)
331 return ((v >> 1) ^ sign) - sign;
336 int i, j,
ret, rbsp_size, aspect_ratio_idc, pic_order_cnt_type;
337 int num_ref_frames_in_pic_order_cnt_cycle;
338 int delta_scale, lastScale = 8, nextScale = 8;
339 int sizeOfScalingList;
351 memset(
sps, 0,
sizeof(*
sps));
364 if (
sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
365 sps->profile_idc == 122 ||
sps->profile_idc == 244 ||
sps->profile_idc == 44 ||
366 sps->profile_idc == 83 ||
sps->profile_idc == 86 ||
sps->profile_idc == 118 ||
367 sps->profile_idc == 128 ||
sps->profile_idc == 138 ||
sps->profile_idc == 139 ||
368 sps->profile_idc == 134) {
370 if (
sps->chroma_format_idc == 3) {
377 for (
i = 0;
i < ((
sps->chroma_format_idc != 3) ? 8 : 12);
i++) {
382 sizeOfScalingList =
i < 6 ? 16 : 64;
383 for (j = 0; j < sizeOfScalingList; j++) {
384 if (nextScale != 0) {
386 nextScale = (lastScale + delta_scale) & 0xff;
388 lastScale = nextScale == 0 ? lastScale : nextScale;
393 sps->chroma_format_idc = 1;
394 sps->bit_depth_luma = 8;
395 sps->bit_depth_chroma = 8;
401 if (pic_order_cnt_type == 0) {
403 }
else if (pic_order_cnt_type == 1) {
408 for (
i = 0;
i < num_ref_frames_in_pic_order_cnt_cycle;
i++)
418 if (!
sps->frame_mbs_only_flag)
432 aspect_ratio_idc =
get_bits(&gb, 8);
433 if (aspect_ratio_idc == 0xff) {