| 607 | } |
| 608 | |
| 609 | static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, |
| 610 | int *got_packet) |
| 611 | { |
| 612 | X264Context *x4 = ctx->priv_data; |
| 613 | x264_nal_t *nal; |
| 614 | int nnal, ret; |
| 615 | x264_picture_t pic_out = {0}, *pic_in; |
| 616 | enum AVPictureType pict_type; |
| 617 | int64_t wallclock = 0; |
| 618 | X264Opaque *out_opaque; |
| 619 | |
| 620 | ret = setup_frame(ctx, frame, &pic_in); |
| 621 | if (ret < 0) |
| 622 | return ret; |
| 623 | |
| 624 | do { |
| 625 | if (x264_encoder_encode(x4->enc, &nal, &nnal, pic_in, &pic_out) < 0) |
| 626 | return AVERROR_EXTERNAL; |
| 627 | |
| 628 | if (nnal && (ctx->flags & AV_CODEC_FLAG_RECON_FRAME)) { |
| 629 | AVCodecInternal *avci = ctx->internal; |
| 630 | |
| 631 | av_frame_unref(avci->recon_frame); |
| 632 | |
| 633 | avci->recon_frame->format = csp_to_pixfmt(pic_out.img.i_csp); |
| 634 | if (avci->recon_frame->format == AV_PIX_FMT_NONE) { |
| 635 | av_log(ctx, AV_LOG_ERROR, |
| 636 | "Unhandled reconstructed frame colorspace: %d\n", |
| 637 | pic_out.img.i_csp); |
| 638 | return AVERROR(ENOSYS); |
| 639 | } |
| 640 | |
| 641 | avci->recon_frame->width = ctx->width; |
| 642 | avci->recon_frame->height = ctx->height; |
| 643 | for (int i = 0; i < pic_out.img.i_plane; i++) { |
| 644 | avci->recon_frame->data[i] = pic_out.img.plane[i]; |
| 645 | avci->recon_frame->linesize[i] = pic_out.img.i_stride[i]; |
| 646 | } |
| 647 | |
| 648 | ret = av_frame_make_writable(avci->recon_frame); |
| 649 | if (ret < 0) { |
| 650 | av_frame_unref(avci->recon_frame); |
| 651 | return ret; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | ret = encode_nals(ctx, pkt, nal, nnal); |
| 656 | if (ret < 0) |
| 657 | return ret; |
| 658 | } while (!ret && !frame && x264_encoder_delayed_frames(x4->enc)); |
| 659 | |
| 660 | if (!ret) |
| 661 | return 0; |
| 662 | |
| 663 | pkt->pts = pic_out.i_pts; |
| 664 | pkt->dts = pic_out.i_dts; |
| 665 | |
| 666 | out_opaque = pic_out.opaque; |
nothing calls this directly
no test coverage detected