| 757 | } |
| 758 | |
| 759 | HRESULT decklink_input_callback::VideoInputFrameArrived( |
| 760 | IDeckLinkVideoInputFrame_v14_2_1 *videoFrame, IDeckLinkAudioInputPacket *audioFrame) |
| 761 | { |
| 762 | void *frameBytes; |
| 763 | void *audioFrameBytes; |
| 764 | BMDTimeValue frameTime; |
| 765 | BMDTimeValue frameDuration; |
| 766 | int64_t wallclock = 0, abs_wallclock = 0; |
| 767 | int64_t video_pkt_pts, audio_pkt_pts; |
| 768 | struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data; |
| 769 | |
| 770 | if (ctx->autodetect) { |
| 771 | if (videoFrame && !(videoFrame->GetFlags() & bmdFrameHasNoInputSource) && |
| 772 | ctx->bmd_mode == bmdModeUnknown) |
| 773 | { |
| 774 | ctx->bmd_mode = AUTODETECT_DEFAULT_MODE; |
| 775 | } |
| 776 | return S_OK; |
| 777 | } |
| 778 | |
| 779 | // Drop the frames till system's timestamp aligns with the configured value. |
| 780 | if (0 == ctx->frameCount && cctx->timestamp_align) { |
| 781 | AVRational remainder = av_make_q(av_gettime() % cctx->timestamp_align, 1000000); |
| 782 | AVRational frame_duration = av_inv_q(ctx->video_st->r_frame_rate); |
| 783 | if (av_cmp_q(remainder, frame_duration) > 0) { |
| 784 | ++ctx->dropped; |
| 785 | return S_OK; |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | ctx->frameCount++; |
| 790 | if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK) |
| 791 | wallclock = av_gettime_relative(); |
| 792 | if (ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK) |
| 793 | abs_wallclock = av_gettime(); |
| 794 | video_pkt_pts = get_pkt_pts(videoFrame, audioFrame, wallclock, abs_wallclock, ctx->video_pts_source, ctx->video_st->time_base, &initial_video_pts, cctx->copyts); |
| 795 | audio_pkt_pts = get_pkt_pts(videoFrame, audioFrame, wallclock, abs_wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts, cctx->copyts); |
| 796 | |
| 797 | // Handle Video Frame |
| 798 | if (videoFrame) { |
| 799 | AVPacket pkt = { 0 }; |
| 800 | if (ctx->frameCount % 25 == 0) { |
| 801 | unsigned long long qsize = ff_decklink_packet_queue_size(&ctx->queue); |
| 802 | av_log(avctx, AV_LOG_DEBUG, |
| 803 | "Frame received (#%lu) - Valid (%liB) - QSize %fMB\n", |
| 804 | ctx->frameCount, |
| 805 | videoFrame->GetRowBytes() * videoFrame->GetHeight(), |
| 806 | (double)qsize / 1024 / 1024); |
| 807 | } |
| 808 | |
| 809 | videoFrame->GetBytes(&frameBytes); |
| 810 | videoFrame->GetStreamTime(&frameTime, &frameDuration, |
| 811 | ctx->video_st->time_base.den); |
| 812 | |
| 813 | if (videoFrame->GetFlags() & bmdFrameHasNoInputSource) { |
| 814 | if (ctx->signal_loss_action == SIGNAL_LOSS_BARS && videoFrame->GetPixelFormat() == bmdFormat8BitYUV) { |
| 815 | unsigned bars[8] = { |
| 816 | 0xEA80EA80, 0xD292D210, 0xA910A9A5, 0x90229035, |
nothing calls this directly
no test coverage detected