28 #define UNCHECKED_BITSTREAM_READER 1
44 int next_avc= h->
is_avc ? 0 : buf_size;
54 for (i = 0; i < buf_size; i++) {
59 nalsize = (nalsize << 8) | buf[i++];
60 if (nalsize <= 0 || nalsize > buf_size - i) {
64 next_avc = i + nalsize;
72 }
else if (state <= 2) {
79 }
else if (state <= 5) {
80 int nalu_type = buf[i] & 0x1F;
122 return i - (state & 5) - 5 * (state > 7);
139 for (list = 0; list < h->
list_count; list++) {
142 for (index = 0; ; index++) {
145 if (reordering_of_pic_nums_idc < 3)
147 else if (reordering_of_pic_nums_idc > 3) {
149 "illegal reordering_of_pic_nums_idc %d\n",
150 reordering_of_pic_nums_idc);
157 "reference count %d overflow\n", index);
175 "illegal memory management control operation %d\n",
208 int buf_index, next_avc;
210 unsigned int slice_type;
211 int state = -1, got_reset = 0;
213 int q264 = buf_size >=4 && !memcmp(
"Q264", buf, 4);
229 next_avc = h->
is_avc ? 0 : buf_size;
231 int src_length, dst_length, consumed, nalsize = 0;
233 if (buf_index >= next_avc) {
237 next_avc = buf_index + nalsize;
240 if (buf_index >= buf_size)
242 if (buf_index >= next_avc)
245 src_length = next_avc - buf_index;
247 state = buf[buf_index];
248 switch (state & 0x1f) {
252 if ((state & 0x1f) ==
NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
259 if (src_length > 1000)
265 &consumed, src_length);
266 if (!ptr || dst_length < 0)
269 buf_index += consumed;
301 "pps_id %u out of range\n", pps_id);
306 "non-existing PPS %u referenced\n", pps_id);
312 "non-existing SPS %u referenced\n", h->
pps.
sps_id);
355 field_poc[0] = field_poc[1] = INT_MAX;
428 if (field_poc[0] < field_poc[1])
430 else if (field_poc[0] > field_poc[1])
455 const uint8_t **poutbuf,
int *poutbuf_size,
497 if (h->sei_cpb_removal_delay >= 0) {
498 s->dts_sync_point = h->sei_buffering_period_present;
499 s->dts_ref_dts_delta = h->sei_cpb_removal_delay;
500 s->pts_dts_delta = h->sei_dpb_output_delay;
502 s->dts_sync_point = INT_MIN;
503 s->dts_ref_dts_delta = INT_MIN;
504 s->pts_dts_delta = INT_MIN;
512 *poutbuf_size = buf_size;
524 for (i = 0; i <= buf_size; i++) {
525 if ((state & 0xFFFFFF1F) == 0x107)
527 if ((state & 0xFFFFFF1F) == 0x108)
534 if ((state & 0xFFFFFF00) == 0x100 && ((state & 0xFFFFFF1F) != 0x106 || has_pps) &&
535 (state & 0xFFFFFF1F) != 0x107 && (state & 0xFFFFFF1F) != 0x108 &&
536 (state & 0xFFFFFF1F) != 0x109 && (state & 0xFFFFFF1F) != 0x10d &&
537 (state & 0xFFFFFF1F) != 0x10f) {
539 while (i > 4 && buf[i - 5] == 0)
545 state = (state << 8) | buf[i];
573 .parser_close =
close,