| 587 | } |
| 588 | |
| 589 | static int h264_parse(AVCodecParserContext *s, |
| 590 | AVCodecContext *avctx, |
| 591 | const uint8_t **poutbuf, int *poutbuf_size, |
| 592 | const uint8_t *buf, int buf_size) |
| 593 | { |
| 594 | H264ParseContext *p = s->priv_data; |
| 595 | ParseContext *pc = &p->pc; |
| 596 | AVRational time_base = { 0, 1 }; |
| 597 | int next; |
| 598 | |
| 599 | if (!p->got_first) { |
| 600 | p->got_first = 1; |
| 601 | if (avctx->extradata_size) { |
| 602 | ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size, |
| 603 | &p->ps, &p->is_avc, &p->nal_length_size, |
| 604 | avctx->err_recognition, avctx); |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { |
| 609 | next = buf_size; |
| 610 | } else { |
| 611 | next = h264_find_frame_end(p, buf, buf_size, avctx); |
| 612 | |
| 613 | if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { |
| 614 | *poutbuf = NULL; |
| 615 | *poutbuf_size = 0; |
| 616 | return buf_size; |
| 617 | } |
| 618 | |
| 619 | if (next < 0 && next != END_NOT_FOUND) { |
| 620 | av_assert1(pc->last_index + next >= 0); |
| 621 | h264_find_frame_end(p, &pc->buffer[pc->last_index + next], -next, avctx); // update state |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | parse_nal_units(s, avctx, buf, buf_size); |
| 626 | |
| 627 | if (avctx->framerate.num) |
| 628 | time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){2, 1})); |
| 629 | if (p->sei.picture_timing.cpb_removal_delay >= 0) { |
| 630 | s->dts_sync_point = p->sei.buffering_period.present; |
| 631 | s->dts_ref_dts_delta = p->sei.picture_timing.cpb_removal_delay; |
| 632 | s->pts_dts_delta = p->sei.picture_timing.dpb_output_delay; |
| 633 | } else { |
| 634 | s->dts_sync_point = INT_MIN; |
| 635 | s->dts_ref_dts_delta = INT_MIN; |
| 636 | s->pts_dts_delta = INT_MIN; |
| 637 | } |
| 638 | |
| 639 | if (s->flags & PARSER_FLAG_ONCE) { |
| 640 | s->flags &= PARSER_FLAG_COMPLETE_FRAMES; |
| 641 | } |
| 642 | |
| 643 | if (s->dts_sync_point >= 0) { |
| 644 | int64_t den = time_base.den * (int64_t)avctx->pkt_timebase.num; |
| 645 | if (den > 0) { |
| 646 | int64_t num = time_base.num * (int64_t)avctx->pkt_timebase.den; |
nothing calls this directly
no test coverage detected