| 657 | } |
| 658 | |
| 659 | static int64_t get_pkt_pts(IDeckLinkVideoInputFrame_v14_2_1 *videoFrame, |
| 660 | IDeckLinkAudioInputPacket *audioFrame, |
| 661 | int64_t wallclock, |
| 662 | int64_t abs_wallclock, |
| 663 | DecklinkPtsSource pts_src, |
| 664 | AVRational time_base, int64_t *initial_pts, |
| 665 | int copyts) |
| 666 | { |
| 667 | int64_t pts = AV_NOPTS_VALUE; |
| 668 | BMDTimeValue bmd_pts; |
| 669 | BMDTimeValue bmd_duration; |
| 670 | HRESULT res = E_INVALIDARG; |
| 671 | switch (pts_src) { |
| 672 | case PTS_SRC_AUDIO: |
| 673 | if (audioFrame) |
| 674 | res = audioFrame->GetPacketTime(&bmd_pts, time_base.den); |
| 675 | break; |
| 676 | case PTS_SRC_VIDEO: |
| 677 | if (videoFrame) |
| 678 | res = videoFrame->GetStreamTime(&bmd_pts, &bmd_duration, time_base.den); |
| 679 | break; |
| 680 | case PTS_SRC_REFERENCE: |
| 681 | if (videoFrame) |
| 682 | res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration); |
| 683 | break; |
| 684 | case PTS_SRC_WALLCLOCK: |
| 685 | /* fall through */ |
| 686 | case PTS_SRC_ABS_WALLCLOCK: |
| 687 | { |
| 688 | /* MSVC does not support compound literals like AV_TIME_BASE_Q |
| 689 | * in C++ code (compiler error C4576) */ |
| 690 | AVRational timebase; |
| 691 | timebase.num = 1; |
| 692 | timebase.den = AV_TIME_BASE; |
| 693 | if (pts_src == PTS_SRC_WALLCLOCK) |
| 694 | pts = av_rescale_q(wallclock, timebase, time_base); |
| 695 | else |
| 696 | pts = av_rescale_q(abs_wallclock, timebase, time_base); |
| 697 | break; |
| 698 | } |
| 699 | } |
| 700 | if (res == S_OK) |
| 701 | pts = bmd_pts / time_base.num; |
| 702 | |
| 703 | if (!copyts) { |
| 704 | if (pts != AV_NOPTS_VALUE && *initial_pts == AV_NOPTS_VALUE) |
| 705 | *initial_pts = pts; |
| 706 | if (*initial_pts != AV_NOPTS_VALUE) |
| 707 | pts -= *initial_pts; |
| 708 | } |
| 709 | |
| 710 | return pts; |
| 711 | } |
| 712 | |
| 713 | static int get_bmd_timecode(AVFormatContext *avctx, AVTimecode *tc, AVRational frame_rate, BMDTimecodeFormat tc_format, IDeckLinkVideoInputFrame_v14_2_1 *videoFrame) |
| 714 | { |
no test coverage detected