28 #define UNCHECKED_BITSTREAM_READER 1
52 int next_avc= h->
is_avc ? 0 : buf_size;
61 for (i = 0; i < buf_size; i++) {
66 nalsize = (nalsize << 8) | buf[i++];
67 if (nalsize <= 0 || nalsize > buf_size - i) {
71 next_avc = i + nalsize;
79 }
else if (state <= 2) {
86 }
else if (state <= 5) {
87 int nalu_type = buf[i] & 0x1F;
129 return i - (state & 5) - 5 * (state > 7);
147 for (list = 0; list < h->
list_count; list++) {
150 for (index = 0; ; index++) {
153 if (reordering_of_pic_nums_idc < 3)
155 else if (reordering_of_pic_nums_idc > 3) {
157 "illegal reordering_of_pic_nums_idc %d\n",
158 reordering_of_pic_nums_idc);
165 "reference count %d overflow\n", index);
183 "illegal memory management control operation %d\n",
217 int buf_index, next_avc;
219 unsigned int slice_type;
220 int state = -1, got_reset = 0;
222 int q264 = buf_size >=4 && !memcmp(
"Q264", buf, 4);
238 next_avc = h->
is_avc ? 0 : buf_size;
240 int src_length, dst_length, consumed, nalsize = 0;
242 if (buf_index >= next_avc) {
246 next_avc = buf_index + nalsize;
249 if (buf_index >= buf_size)
251 if (buf_index >= next_avc)
254 src_length = next_avc - buf_index;
256 state = buf[buf_index];
257 switch (state & 0x1f) {
261 if ((state & 0x1f) ==
NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
268 if (src_length > 1000)
274 &consumed, src_length);
275 if (!ptr || dst_length < 0)
278 buf_index += consumed;
310 "pps_id %u out of range\n", pps_id);
315 "non-existing PPS %u referenced\n", pps_id);
321 "non-existing SPS %u referenced\n", h->
pps.
sps_id);
393 field_poc[0] = field_poc[1] = INT_MAX;
466 if (field_poc[0] < field_poc[1])
468 else if (field_poc[0] > field_poc[1])
493 const uint8_t **poutbuf,
int *poutbuf_size,
536 if (h->sei_cpb_removal_delay >= 0) {
537 s->dts_sync_point = h->sei_buffering_period_present;
538 s->dts_ref_dts_delta = h->sei_cpb_removal_delay;
539 s->pts_dts_delta = h->sei_dpb_output_delay;
541 s->dts_sync_point = INT_MIN;
542 s->dts_ref_dts_delta = INT_MIN;
543 s->pts_dts_delta = INT_MIN;
551 *poutbuf_size = buf_size;
566 if ((state & 0xFFFFFF00) != 0x100)
568 nalu_type = state & 0x1F;
571 }
else if (nalu_type ==
NAL_PPS)
578 else if ((nalu_type !=
NAL_SEI || has_pps) &&
582 while (ptr - 4 > buf && ptr[-5] == 0)
584 return ptr - 4 -
buf;