History

avdevice/decklink: addition of absolute wallclock option for pts source

Vishwanath Dixit committed 8 years ago

Commit fc93eca1 parent dfa25235 files · +19 −7Browse files

Unified · Split

5 files
  1. doc/indevs.texi +4 −2
  2. libavdevice/decklink_common_c.h +1 −0
  3. libavdevice/decklink_dec.cpp +12 −4
  4. libavdevice/decklink_dec_c.c +1 −0
  5. libavdevice/version.h +1 −1
doc/indevs.texi+4−2
@@ -298,11 +298,13 @@ Sets the audio input source. Must be @samp{unset}, @samp{embedded}, · 297 unmodified lines
298 298
299@item video_pts299@item video_pts
300Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},300Sets the video packet timestamp source. Must be @samp{video}, @samp{audio},
301@samp{reference} or @samp{wallclock}. Defaults to @samp{video}.301@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
302Defaults to @samp{video}.
302 303
303@item audio_pts304@item audio_pts
304Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},305Sets the audio packet timestamp source. Must be @samp{video}, @samp{audio},
305@samp{reference} or @samp{wallclock}. Defaults to @samp{audio}.306@samp{reference}, @samp{wallclock} or @samp{abs_wallclock}.
307Defaults to @samp{audio}.
306 308
307@item draw_bars309@item draw_bars
308If set to @samp{true}, color bars are drawn in the event of a signal loss.310If set to @samp{true}, color bars are drawn in the event of a signal loss.
libavdevice/decklink_common_c.h+1−0
@@ -28,6 +28,7 @@ typedef enum DecklinkPtsSource { · 27 unmodified lines
28 PTS_SRC_VIDEO = 2,28 PTS_SRC_VIDEO = 2,
29 PTS_SRC_REFERENCE = 3,29 PTS_SRC_REFERENCE = 3,
30 PTS_SRC_WALLCLOCK = 4,30 PTS_SRC_WALLCLOCK = 4,
31 PTS_SRC_ABS_WALLCLOCK = 5,
31 PTS_SRC_NB32 PTS_SRC_NB
32} DecklinkPtsSource;33} DecklinkPtsSource;
33 34
libavdevice/decklink_dec.cpp+12−4
@@ -585,6 +585,7 @@ ULONG decklink_input_callback::Release(void) · 584 unmodified lines
585static int64_t get_pkt_pts(IDeckLinkVideoInputFrame *videoFrame,585static 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_Q614 /* 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 Frame664 // 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);
libavdevice/decklink_dec_c.c+1−0
@@ -70,6 +70,7 @@ static const AVOption options[] = { · 69 unmodified lines
70 { "video", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_VIDEO }, 0, 0, DEC, "pts_source"},70 { "video", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_VIDEO }, 0, 0, DEC, "pts_source"},
71 { "reference", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, "pts_source"},71 { "reference", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_REFERENCE}, 0, 0, DEC, "pts_source"},
72 { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"},72 { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_WALLCLOCK}, 0, 0, DEC, "pts_source"},
73 { "abs_wallclock", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PTS_SRC_ABS_WALLCLOCK}, 0, 0, DEC, "pts_source"},
73 { "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC },74 { "draw_bars", "draw bars on signal loss" , OFFSET(draw_bars), AV_OPT_TYPE_BOOL, { .i64 = 1}, 0, 1, DEC },
74 { "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },75 { "queue_size", "input queue buffer size", OFFSET(queue_size), AV_OPT_TYPE_INT64, { .i64 = (1024 * 1024 * 1024)}, 0, INT64_MAX, DEC },
75 { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC },76 { "audio_depth", "audio bitdepth (16 or 32)", OFFSET(audio_depth), AV_OPT_TYPE_INT, { .i64 = 16}, 16, 32, DEC },
libavdevice/version.h+1−1
@@ -29,7 +29,7 @@ · 28 unmodified lines
29 29
30#define LIBAVDEVICE_VERSION_MAJOR 5830#define LIBAVDEVICE_VERSION_MAJOR 58
31#define LIBAVDEVICE_VERSION_MINOR 031#define LIBAVDEVICE_VERSION_MINOR 0
32#define LIBAVDEVICE_VERSION_MICRO 10032#define LIBAVDEVICE_VERSION_MICRO 101
33 33
34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \34#define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \
35 LIBAVDEVICE_VERSION_MINOR, \35 LIBAVDEVICE_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t