Showing the changes to libavdevice/decklink_dec.cpp (1 of 5 files). Show all
Unified · Split
| @@ -585,6 +585,7 @@ ULONG decklink_input_callback::Release(void) · 584 unmodified lines | |||
| 585 | static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, | 585 | static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, |
| 586 | IDeckLinkAudioInputPacket *audioFrame, | 586 | IDeckLinkAudioInputPacket *audioFrame, |
| 587 | int64_t wallclock, | 587 | int64_t wallclock, |
| 588 | int64_t abs_wallclock, | ||
| 588 | DecklinkPtsSource pts_src, | 589 | DecklinkPtsSource pts_src, |
| 589 | AVRational time_base, int64_t *initial_pts, | 590 | AVRational time_base, int64_t *initial_pts, |
| 590 | int copyts) | 591 | int copyts) |
| @@ -607,13 +608,18 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame, · 16 unmodified lines | |||
| 607 | res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration); | 608 | res = videoFrame->GetHardwareReferenceTimestamp(time_base.den, &bmd_pts, &bmd_duration); |
| 608 | break; | 609 | break; |
| 609 | case PTS_SRC_WALLCLOCK: | 610 | case PTS_SRC_WALLCLOCK: |
| 611 | /* fall through */ | ||
| 612 | case PTS_SRC_ABS_WALLCLOCK: | ||
| 610 | { | 613 | { |
| 611 | /* MSVC does not support compound literals like AV_TIME_BASE_Q | 614 | /* MSVC does not support compound literals like AV_TIME_BASE_Q |
| 612 | * in C++ code (compiler error C4576) */ | 615 | * in C++ code (compiler error C4576) */ |
| 613 | AVRational timebase; | 616 | AVRational timebase; |
| 614 | timebase.num = 1; | 617 | timebase.num = 1; |
| 615 | timebase.den = AV_TIME_BASE; | 618 | timebase.den = AV_TIME_BASE; |
| 616 | pts = av_rescale_q(wallclock, timebase, time_base); | 619 | if (pts_src == PTS_SRC_WALLCLOCK) |
| 620 | pts = av_rescale_q(wallclock, timebase, time_base); | ||
| 621 | else | ||
| 622 | pts = av_rescale_q(abs_wallclock, timebase, time_base); | ||
| 617 | break; | 623 | break; |
| 618 | } | 624 | } |
| 619 | } | 625 | } |
| @@ -637,7 +643,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 17 unmodified lines | |||
| 637 | void *audioFrameBytes; | 643 | void *audioFrameBytes; |
| 638 | BMDTimeValue frameTime; | 644 | BMDTimeValue frameTime; |
| 639 | BMDTimeValue frameDuration; | 645 | BMDTimeValue frameDuration; |
| 640 | int64_t wallclock = 0; | 646 | int64_t wallclock = 0, abs_wallclock = 0; |
| 641 | struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data; | 647 | struct decklink_cctx *cctx = (struct decklink_cctx *) avctx->priv_data; |
| 642 | 648 | ||
| 643 | if (ctx->autodetect) { | 649 | if (ctx->autodetect) { |
| @@ -652,6 +658,8 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 8 unmodified lines | |||
| 652 | ctx->frameCount++; | 658 | ctx->frameCount++; |
| 653 | if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK) | 659 | if (ctx->audio_pts_source == PTS_SRC_WALLCLOCK || ctx->video_pts_source == PTS_SRC_WALLCLOCK) |
| 654 | wallclock = av_gettime_relative(); | 660 | wallclock = av_gettime_relative(); |
| 661 | if (ctx->audio_pts_source == PTS_SRC_ABS_WALLCLOCK || ctx->video_pts_source == PTS_SRC_ABS_WALLCLOCK) | ||
| 662 | abs_wallclock = av_gettime(); | ||
| 655 | 663 | ||
| 656 | // Handle Video Frame | 664 | // Handle Video Frame |
| 657 | if (videoFrame) { | 665 | if (videoFrame) { |
| @@ -698,7 +706,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 40 unmodified lines | |||
| 698 | no_video = 0; | 706 | no_video = 0; |
| 699 | } | 707 | } |
| 700 | 708 | ||
| 701 | pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->video_pts_source, ctx->video_st->time_base, &initial_video_pts, cctx->copyts); | 709 | pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, abs_wallclock, ctx->video_pts_source, ctx->video_st->time_base, &initial_video_pts, cctx->copyts); |
| 702 | pkt.dts = pkt.pts; | 710 | pkt.dts = pkt.pts; |
| 703 | 711 | ||
| 704 | pkt.duration = frameDuration; | 712 | pkt.duration = frameDuration; |
| @@ -789,7 +797,7 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 84 unmodified lines | |||
| 789 | pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8); | 797 | pkt.size = audioFrame->GetSampleFrameCount() * ctx->audio_st->codecpar->channels * (ctx->audio_depth / 8); |
| 790 | audioFrame->GetBytes(&audioFrameBytes); | 798 | audioFrame->GetBytes(&audioFrameBytes); |
| 791 | audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den); | 799 | audioFrame->GetPacketTime(&audio_pts, ctx->audio_st->time_base.den); |
| 792 | pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts, cctx->copyts); | 800 | pkt.pts = get_pkt_pts(videoFrame, audioFrame, wallclock, abs_wallclock, ctx->audio_pts_source, ctx->audio_st->time_base, &initial_audio_pts, cctx->copyts); |
| 793 | pkt.dts = pkt.pts; | 801 | pkt.dts = pkt.pts; |
| 794 | 802 | ||
| 795 | //fprintf(stderr,"Audio Frame size %d ts %d\n", pkt.size, pkt.pts); | 803 | //fprintf(stderr,"Audio Frame size %d ts %d\n", pkt.size, pkt.pts); |