34 uint8_t *buf, *end, *start;
35 uint8_t *
sps, *
pps, *sps_ext;
36 uint32_t sps_size = 0, pps_size = 0, sps_ext_size = 0;
37 int ret, nb_sps = 0, nb_pps = 0, nb_sps_ext = 0;
66 while (end - buf > 4) {
71 nal_type = buf[0] & 0x1f;
81 }
else if (nal_type == 8) {
89 }
else if (nal_type == 13) {
91 if (
size > UINT16_MAX || nb_sps_ext >= 256) {
105 if (sps_size < 6 || !pps_size) {
121 if (
sps[3] != 66 &&
sps[3] != 77 &&
sps[3] != 88) {
146 uint16_t sps_size, pps_size;
153 if (*
size < 11 || in[0] != 1)
157 if (11 + sps_size > *
size)
159 pps_size =
AV_RB16(&in[9 + sps_size]);
160 if (11 + sps_size + pps_size > *
size)
167 memcpy(
out + 4, &in[8], sps_size);
169 memcpy(
out + 8 + sps_size, &in[11 + sps_size], pps_size);
205 return ((v >> 1) ^ sign) - sign;
210 int i, j,
ret, rbsp_size, aspect_ratio_idc, pic_order_cnt_type;
211 int num_ref_frames_in_pic_order_cnt_cycle;
212 int delta_scale, lastScale = 8, nextScale = 8;
213 int sizeOfScalingList;
225 memset(
sps, 0,
sizeof(*
sps));
238 if (
sps->profile_idc == 100 ||
sps->profile_idc == 110 ||
239 sps->profile_idc == 122 ||
sps->profile_idc == 244 ||
sps->profile_idc == 44 ||
240 sps->profile_idc == 83 ||
sps->profile_idc == 86 ||
sps->profile_idc == 118 ||
241 sps->profile_idc == 128 ||
sps->profile_idc == 138 ||
sps->profile_idc == 139 ||
242 sps->profile_idc == 134) {
244 if (
sps->chroma_format_idc == 3) {
251 for (
i = 0;
i < ((
sps->chroma_format_idc != 3) ? 8 : 12);
i++) {
256 sizeOfScalingList =
i < 6 ? 16 : 64;
257 for (j = 0; j < sizeOfScalingList; j++) {
258 if (nextScale != 0) {
260 nextScale = (lastScale + delta_scale) & 0xff;
262 lastScale = nextScale == 0 ? lastScale : nextScale;
267 sps->chroma_format_idc = 1;
268 sps->bit_depth_luma = 8;
269 sps->bit_depth_chroma = 8;
275 if (pic_order_cnt_type == 0) {
277 }
else if (pic_order_cnt_type == 1) {
282 for (
i = 0;
i < num_ref_frames_in_pic_order_cnt_cycle;
i++)
292 if (!
sps->frame_mbs_only_flag)
306 aspect_ratio_idc =
get_bits(&gb, 8);
307 if (aspect_ratio_idc == 0xff) {